www.digitalmars.com         C & C++   DMDScript  

D - throw

reply "Pavel Minayev" <evilone omen.ru> writes:
Why doesn't D allow throw statement without arguments? In C++ it rethrows
the exception being processed, what's bad in it?
Mar 13 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a6mlkb$1ada$1 digitaldaemon.com...
 Why doesn't D allow throw statement without arguments? In C++ it rethrows
 the exception being processed, what's bad in it?

I just didn't think that added much of anything.
Mar 12 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Walter" <walter digitalmars.com> wrote in message
news:a6n1po$1fp3$1 digitaldaemon.com...

 I just didn't think that added much of anything.

Why? A very convenient feature. Besides, it allows to omit argument name in catch blocks: try { ... } catch (OutOfMemory) { // do something useful here throw; }
Mar 13 2002
parent reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
Pavel Minayev wrote:

 "Walter" <walter digitalmars.com> wrote in message
 news:a6n1po$1fp3$1 digitaldaemon.com...

 I just didn't think that added much of anything.

Why? A very convenient feature. Besides, it allows to omit argument name in catch blocks: try { ... } catch (OutOfMemory) { // do something useful here throw; }

It's also useful for reporting errors of unrecognized exceptions: try { ... } catch(...) { printf("error in myfunc(): "); throw; }; -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]
Mar 13 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3C8F83A7.6B5C1214 deming-os.org...
 Pavel Minayev wrote:

 "Walter" <walter digitalmars.com> wrote in message
 news:a6n1po$1fp3$1 digitaldaemon.com...

 I just didn't think that added much of anything.

Why? A very convenient feature. Besides, it allows to omit argument name in catch blocks: try { ... } catch (OutOfMemory) { // do something useful here throw; }

It's also useful for reporting errors of unrecognized exceptions: try { ... } catch(...) { printf("error in myfunc(): "); throw; };

Just use: catch(Object o) { ... throw o; }
Mar 13 2002
parent "Pavel Minayev" <evilone omen.ru> writes:
"Walter" <walter digitalmars.com> wrote in message
news:a6o83v$208d$1 digitaldaemon.com...

 Just use:
     catch(Object o)
     {
         ...
         throw o;
     }

Yes, I remember that only objects can be thrown in D. Yet, "throw;" seems to be a convenient feature to me. Something that can be accomplished by other means, but just makes your life a bit easier.
Mar 13 2002