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

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 5 08:56:36 PDT 2014


On 2014-10-05 17:08, Marco Leise wrote:

> Nice, finally someone who actually wants to discern Exception
> types. I'm always at a loss as to what warrants its own
> exception type.

Yeah, that can be quite difficult. In the end, if you have a good 
exception hierarchy I don't think it will hurt to have many different 
exception types.

> E.g. when looking at network protocols, would
> a 503 be a NetworkException, a HTTPException or a
> HTTPInternalServerErrorException ?

For this specific case I would probably have one general exception for 
all HTTP error codes.

> Where do *you* wish libraries would differentiate?

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.

> Or does it really come down to categories like "illegal
> argument", "division by zero", "null pointer", "out of memory"
> for you?
>

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list