|
|
|
|
|
by fennecfoxen
1720 days ago
|
|
I feel a lot of the problem here is that someone make the FooLibrary that does some file system call and sometimes throws some IOError. Later on a new backend goes over the network and it throws a NetworkError now too. This is a leaked abstraction. These are both a kind of FooError. If you’re using a strong enough type system that cares about these things, you should be using it to invest in that sort of strong encapsulation, too. Each API layer should be a translation layer. Needless to say, this is a fair bit of work, and takes a fair amount of rigor, so it usually won’t happen. |
|
On the other hand, if FooLibrary tries to read some config file or fetch metadata over the internet, then that's a sort of detail that it shouldn't bother the caller with. It should either handle the exception or translate it to a FooException.