Program logic bugs vs input/environmental errors (checked exceptions)

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 5 23:39:38 PDT 2014


06-Oct-2014 10:33, Jacob Carlborg пишет:
> On 05/10/14 23:50, Dmitry Olshansky wrote:
>
>> 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.
>
> Why not just define two different PermissionException?

Rather N permission exceptions. It gets worse with more problem domains 
to cover. Again the trick is being able to catch all 
PermissionExceptions, including for exception type you may not know in 
advance.

It's obvious to me that one hierarchy is way to limiting for exceptions, 
simply because there could be many ways to categorize the same set of 
error conditions.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list