Why exceptions for error handling is so important

via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 14 09:57:58 PST 2015


On Wednesday, 14 January 2015 at 17:45:28 UTC, deadalnix wrote:
> It is an example "I have no idea what to do about this". The 
> code throwing the exception is faced with a situation where it 
> cannot continue (assuming this code is expected to generate a 
> webpage or something like that) but at the same time, is not in 
> a position to perform the custom http so it is bailing out.

No, "201" means success, resource created, and "409" means that 
it was not carried out because of conflict in the request. 
However, these may be meaningful responses to the client based on 
the input, like "204" no content. So it is output.

Throwing an exception is just an efficient way to abort all 
resources and queries that may be in progress and return a status 
to the client in a clean fashion when you don't need a text body. 
Just a mechanism. And it makes sense if used consistently.


More information about the Digitalmars-d mailing list