exceptions vs error codes

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 10 14:33:15 PDT 2016


On Sun, 10 Jul 2016 17:19:31 +0000, phant0m wrote:
> Usually,
> only a calling context can fix the error and continue execution of the
> program. If exception caught by a top level handler, all it can do is
> just a crash.

We separate execution into tasks (which could be messages in SQS, or RPCs 
with a REST interface, or executing a bit of AI script in a game). We 
observe a failure in a task. Instead of trying to do something 
intelligent about it inside the implementation of the task, we blindly 
retry the task with backoff, if appropriate.

After a task has failed enough times, it's put into an error queue and 
the developers are notified.

> Moreover, with exceptions, you need to wrap every piece of
> code with ugly "try/catch".

Only on a code coverage level. Manual return value checking requires it 
on a syntactic level. That's why my Go programs are about 20% error 
checking -- and I *still* have to use try/catch (defer/recover, whatever, 
it's the same thing).


More information about the Digitalmars-d mailing list