Why exceptions for error handling is so important

via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 12 10:11:01 PST 2015


On Monday, 12 January 2015 at 17:57:10 UTC, H. S. Teoh via 
Digitalmars-d wrote:
> Yeah, exceptions are supposed to be ... well, *exceptions*, 
> rather than
> the norm. :-) If you're using exceptions to do flow control, 
> you're
> doing something wrong.

I'm sorry, but this is just a crappy excuse invented to defend 
C++ EH. It has no merits, except being an excuse for writing 
exceptionally convoluted code to save performance because real 
exceptions are slow.

(Everything that involves a state change is essentially flow 
control if we are going down to basics.)

There are plenty of situations where exceptions used for retries 
is the most sensible solution. Heck, that's even how x86 floating 
point exceptions work.

There are plenty of situations where returning state with 
exceptions makes the most sense, e.g. a web service request 
handler.


More information about the Digitalmars-d mailing list