Thread overview
error vs exception
Aug 23, 2004
Ben Hinkle
Aug 23, 2004
Sean Kelly
Aug 24, 2004
Ben Hinkle
Aug 26, 2004
Stewart Gordon
August 23, 2004
I'm confused about what D calls errors and exceptions. Part of the changes that I've made to std.stream involve changing the Error subclasses to Exception subclasses and I want to make sure this is the right thing to do.

Now, the doc http://www.digitalmars.com/d/errors.html talks about the class Error and how it can be caught and handled. It also says all errors subclass Error. So that makes me think Errors are recoverable. But then in object.d the source code says:

// Recoverable errors
class Exception : Object ...
// Non-recoverable errors
class Error : Exception ...

I'm used to Exceptions being thrown/caught willy-nilly and Errors being really serious problems that cause the app to abort. In D is it reversed? If so then I'll back out my std.stream changes. Also I suggest some more details in the errors.html doc about the different classes involved and maybe even rename Exception to NonRecoverableError or something (or vide-versa rename Error to NonRecoverableException).

Note I don't want to start a thread about the abstract concepts of recoverable vs non-recoverable errors - I just want to know how those concepts map to D.

-Ben
August 23, 2004
In article <cgcs6d$2ele$1@digitaldaemon.com>, Ben Hinkle says...
>
>I'm confused about what D calls errors and exceptions. Part of the changes that I've made to std.stream involve changing the Error subclasses to Exception subclasses and I want to make sure this is the right thing to do.
>
>Now, the doc http://www.digitalmars.com/d/errors.html talks about the class Error and how it can be caught and handled. It also says all errors subclass Error. So that makes me think Errors are recoverable. But then in object.d the source code says:
>
>// Recoverable errors
>class Exception : Object ...
>// Non-recoverable errors
>class Error : Exception ...
>
>I'm used to Exceptions being thrown/caught willy-nilly and Errors being really serious problems that cause the app to abort. In D is it reversed? If so then I'll back out my std.stream changes. Also I suggest some more details in the errors.html doc about the different classes involved and maybe even rename Exception to NonRecoverableError or something (or vide-versa rename Error to NonRecoverableException).
>
>Note I don't want to start a thread about the abstract concepts of recoverable vs non-recoverable errors - I just want to know how those concepts map to D.

I'm not sure.  Though doFormat (a relatively new addition) throws an exception derived from Error, so I'm guessing that Walter currently considers Errors to be recoverable no matter what the comment says.


Sean


August 24, 2004
> I'm not sure.  Though doFormat (a relatively new addition) throws an
exception
> derived from Error, so I'm guessing that Walter currently considers Errors
to be
> recoverable no matter what the comment says.

holy shiskabobs - you're right. Well, looks like I'll send Walter another version of std.stream with the old Error subclasses. Plus I'll start updating all my code to use Error subclasses instead of Exceptions.


August 26, 2004
Sean Kelly wrote:

<snip>
> I'm not sure.  Though doFormat (a relatively new addition) throws an exception
> derived from Error, so I'm guessing that Walter currently considers Errors to be
> recoverable no matter what the comment says.

Recoverable by whom - the app or the programmer?

A FormatError strikes me as an indication of a bug.

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.