More exception classes into Phobos?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sat Mar 25 07:58:53 PDT 2017


On Saturday, March 25, 2017 14:17:10 Jacob Carlborg via Digitalmars-d wrote:
> On 2017-03-23 21:48, Jonathan M Davis via Digitalmars-d wrote:
> > There are plenty of cases where all you care about is that something
> > went
> > wrong when calling a function and aren't going to do anything special
> > depending on what went wrong. You just handle it and move on.
>
> If you don't know that went wrong you cannot handle it. Basically the
> only option that is left is to abort the program.

In my experience, that's often not true. It could simply mean that you abort
the current operation - especially in programs that act anything like
servers or operate on batches of jobs. Yes, in some cases, you simply can't
do anything useful if the operation failed, and you do have to abort the
program, but that's not always true. It very much depends on what the
program is doing.

Now, if you want to respond in any manner beyond "something went wrong,"
you're likely going to need a more specific exception type that tells you
something about what actually went wrong, but I've seen plenty of code that
really didn't care what went wrong - e.g. it simply logs the error and moves
on to the next operation, or it responds to the program that made the
request that something went wrong and then moves on to the next request.

- Jonathan M Davis



More information about the Digitalmars-d mailing list