2 ms·
His argument that a library that accepts an interface without declaring all possible exceptions a method of that interface might throw is badly designed is misg
by fhars 17y ago
His argument that a library that accepts an interface without declaring all possible exceptions a method of that interface might throw is badly designed is misguided. This assumes that the writer of the library can know all possible custom exceptions that code written by the user might throw, which is impossible. But it is perfectly valid if the code that calls the library passes in an instance implementing the interface that might throw a CantFrobnicateException that the library doesn't know anything about if the calling code knows what to do if the library call fails with that exception.
The real design error here are still checked exceptions. What you really want are dynamic exceptions with an optional whole program analyzer that detects possible code paths that could lead to uncaught exceptions.