05-Oct-2014 20:18, Andrei Alexandrescu пишет:
On 10/5/14, 8:56 AM, Jacob Carlborg wrote:
I would like to have as specific exception type as possible. Also a nice
hierarchy of exception when catching a specific exception is not
interesting. Instead of just a FileException there could be
FileNotFoundException, PermissionDeniedExcepton and so on.

Exceptions are all about centralized error handling. How, and how often,
would you handle FileNotFoundException differently than
PermissionDeniedException?


Seems like it should be possible to define multiple interfaces for exceptions, and then catch by that (and/or combinations of such).

Each of interface would be interested in a particular property of exception. Then catching by:

FileException with PermissionException

would mean OS-level permission viloated and it was during file access,

while

ProcessException with PermissionException would mean process manipulation was forbiden, etc.

Of course, some code may be interested only in PermissionException side of things, while other code may want to contain anything related to files, and the catch-all-sensible-ones inside of the main function.

--
Dmitry Olshansky

Reply via email to