3 ms·
I would disagree that network failure is unusual. It is something you should expect to have happen and should consider reporting such conditions a core feature
by randomdata 5y ago
I would disagree that network failure is unusual. It is something you should expect to have happen and should consider reporting such conditions a core feature of your API design as much as the happy path, not something bolted to the side.
Exceptions are best reserved for conditions that should be impossible, but become possible for an exceptional reason (bugs, cosmic rays flipping the wrong bits, etc.)
- gwbas1c 5y agoIt's really critical that you don't have to litter every single function call and conditional in your code with "if network error." There's plenty of "one in a million" corner cases beyond network errors that an industrial strength program needs to handle. Exceptions let you put a single error handler higher up in the stack for the one in a million errors, like network errors.
- randomdata 5y agoIf a network error is a possible, there is no reason for it to not be a first class feature of your API. You can bolt it on to the side using goto by another name, but you shouldn’t.