www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Standard exception hierarchy

reply Leandro Lucarella <llucarella integratech.com.ar> writes:
Hi! I was looking for any information about how D exceptions are 
arranged and I couldn't find anything but this proposal:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=21456

Is there any standard D exception hierarchy? If not, I think it's a good 
time to have one, because D is getting popular and people will start 
making it's own exception hierarchy and that would be too hard to change 
if D gets a standard hierarchy later.

I think there is a great experience on this on existing languages, and D 
first have to decide if it want to have a small set of exceptions (like 
C++[1] for example) or a little larger one (like Python[2] for example).

I don't really care too much on which way D should take, but I think it 
should take one soon.

[1] 
http://www.roguewave.com/support/docs/sourcepro/edition9-update1/html/stdlibref/exceptions.html
[2] http://docs.python.org/lib/module-exceptions.html

-- 
Leandro Lucarella
Integratech S.A.
4571-5252
Mar 27 2007
parent reply Alberto Bertogli <albertito gmail.com> writes:
On Tue, Mar 27, 2007 at 03:09:38PM -0300, Leandro Lucarella wrote:
 Is there any standard D exception hierarchy? If not, I think it's a good 
 time to have one, because D is getting popular and people will start 
 making it's own exception hierarchy and that would be too hard to change 
 if D gets a standard hierarchy later.
I started to play with D last week and ran into this very quickly. I was writing bindings for some application I wrote (http://auriga.wearlab.de/~alb/nmdb/ is the app, you can browse the bindings at http://repo.or.cz/w/nmdb.git?a=tree;f=d) and I needed to raise an exception where a key in some kind of associative array was not found. I looked up to see the standard hierarchy only to found out there was none, which was a bit of a bummer (the biggest one so far, because D looks quite nice). Then I tried to use the same one used by the standard data type, but it required I give a file and a line number to it, which wasn't very clean either. Finally I had to implement my own, but it would have been much better to have some standard hierarchy to use, or at least to have as a "recommended style reference" for names and inheritance. Are there any plans to work on this? Thanks, Alberto
Mar 29 2007
parent reply kris <foo bar.com> writes:
Alberto Bertogli wrote:
 On Tue, Mar 27, 2007 at 03:09:38PM -0300, Leandro Lucarella wrote:
 
Is there any standard D exception hierarchy? If not, I think it's a good 
time to have one, because D is getting popular and people will start 
making it's own exception hierarchy and that would be too hard to change 
if D gets a standard hierarchy later.
I started to play with D last week and ran into this very quickly. I was writing bindings for some application I wrote (http://auriga.wearlab.de/~alb/nmdb/ is the app, you can browse the bindings at http://repo.or.cz/w/nmdb.git?a=tree;f=d) and I needed to raise an exception where a key in some kind of associative array was not found. I looked up to see the standard hierarchy only to found out there was none, which was a bit of a bummer (the biggest one so far, because D looks quite nice). Then I tried to use the same one used by the standard data type, but it required I give a file and a line number to it, which wasn't very clean either. Finally I had to implement my own, but it would have been much better to have some standard hierarchy to use, or at least to have as a "recommended style reference" for names and inheritance. Are there any plans to work on this? Thanks, Alberto
Tango has an extended set of pre-defined exceptions for this reason, and they live in tango.core.Exception. You might find something there to meet your needs? e.g. IllegalElementException, NoSuchElementException, and IllegalArgumentException
Mar 29 2007
parent reply Leandro Lucarella <llucarella integratech.com.ar> writes:
 Tango has an extended set of pre-defined exceptions for this reason, and 
 they live in tango.core.Exception. You might find something there to 
 meet your needs?
 
 e.g. IllegalElementException, NoSuchElementException, and 
 IllegalArgumentException
But as long as Tango don't replace Phobos and become the official D standard library, this solves nothing about an standard exception hierarchy. -- Leandro Lucarella Integratech S.A. 4571-5252
Mar 30 2007
parent reply Dan <murpsoft hotmail.com> writes:
Leandro Lucarella Wrote:

 But as long as Tango don't replace Phobos and become the official D 
 standard library, this solves nothing about an standard exception hierarchy.
Yeah, it does. Write using the Tango library, and you have a standard exception hierarchy. Unless you mean standard - everyone and everyone has to use it?
Mar 30 2007
parent Leandro Lucarella <llucarella integratech.com.ar> writes:
Dan escribió:
 Leandro Lucarella Wrote:
 
 But as long as Tango don't replace Phobos and become the official D 
 standard library, this solves nothing about an standard exception hierarchy.
Yeah, it does. Write using the Tango library, and you have a standard exception hierarchy. Unless you mean standard - everyone and everyone has to use it?
No, I mean, I download an standard D compiler and I don't get Tango, I have to put an external dependency on my software. Any other library could define it's own "standard" exception hierarchy, but that's not the idea. -- Leandro Lucarella Integratech S.A. 4571-5252
Mar 30 2007