3 ms·
> you only have to expose exceptions you don't handle Which is the vast majority of exceptions because by-definition exceptional conditions can't be handled wi
by wvenable 8y ago
> you only have to expose exceptions you don't handle
Which is the vast majority of exceptions because by-definition exceptional conditions can't be handled within the method. That's why they are exceptions.
The presumption that most exceptions are handled locally is wrong. Exceptions, if they are handled at all, are almost always handled far away from the site they were thrown. Further it doesn't even matter which method it is! I can handle all network errors by restarting the operation from the start; I don't need to know which of the 3,000 possible methods up from my loop actually triggered the network exception. If any of those methods change from throwing to not throwing a network error, it literally doesn't matter. But I do need to know it's a network error and not some abstracted LibraryNameException.
- apta 8y ago> But I do need to know it's a network error and not some abstracted LibraryNameException. How is that any different from using return values like Rust does? It seems that libraries have their own `LibraryError` type which you have to decode anyway.