go-skynet icon indicating copy to clipboard operation
go-skynet copied to clipboard

Review how we handle error codes

Open mrcnski opened this issue 3 years ago • 4 comments

We should know the StatusCodes we should receive and handle them accordingly. Something like a switch statement that handles different codes explicitly and gives a developer error if we have missed one?

Otherwise if that is over the top I think we should explicitly check for success and return an error if not so we aren't hiding any weird status codes that might create UX bugs or inconsistencies for users.

See https://github.com/NebulousLabs/go-skynet/pull/10#pullrequestreview-446519862

I'm thinking we treat >= 200 and < 300 as success and anything else as unexpected and therefore an error.

mrcnski avatar Jul 17 '20 12:07 mrcnski

We need to treat 3xx according to their specification - following redirects, etc. We can choose to return them to the caller, in case the API supports that or we decide that it should support it. But we can't treat a redirect as an error, especially now that siad is using redirects in order to ensure skylinks have a trailing /.

ro-tex avatar Aug 03 '20 12:08 ro-tex

Seems like Go's http client will follow redirects automatically, so there's nothing we need to do there.

mrcnski avatar Aug 06 '20 15:08 mrcnski

In that case I'll close the issue.

ro-tex avatar Aug 17 '20 14:08 ro-tex

I misread. We don't need to do anything special for the 3xx case but we still need to do that rest.

ro-tex avatar Aug 17 '20 14:08 ro-tex