digitalmars.D - Which exception
- Tom (12/12) Oct 29 2006 Hey,
- Frits van Bommel (15/27) Oct 29 2006 I'm sorry, but what *is* it that you need if not the above?
- Tom (7/34) Oct 30 2006 No, you're right. It works here, on a WinXP machine. When I get home lat...
- Frits van Bommel (20/28) Oct 30 2006 Just tried it in my VMWare window:
- Tom (7/42) Oct 30 2006 Shit! the same here. I could swear that yesterday I had code that failed...
Hey, lets say I have something like the following: try { // Code that throws some exception I don't know of. } catch (Exception ex) { writefln(ex.classinfo.name); // works but it's not what I need } Is there some way to get the name of the class 'ex' is instance of (the derived class and not the base class)? Thanks in advance, -- Tom;
Oct 29 2006
Tom wrote:Hey, lets say I have something like the following: try { // Code that throws some exception I don't know of. } catch (Exception ex) { writefln(ex.classinfo.name); // works but it's not what I need } Is there some way to get the name of the class 'ex' is instance of (the derived class and not the base class)?I'm sorry, but what *is* it that you need if not the above? import std.stdio; class DerivedException : Exception { this() { super(""); } } void main() { try { // Code that throws some exception. throw new DerivedException; } catch (Exception ex) { writefln(ex.classinfo.name); // writes "DerivedException" } } The above code writes "DerivedException" to stdout, which is the name of the most derived class ex is an instance of. Am I missing something?
Oct 29 2006
== Quote from Frits van Bommel (fvbommel REMwOVExCAPSs.nl)'s articleTom wrote:No, you're right. It works here, on a WinXP machine. When I get home later, I'll test it on my Linux, where it didn't work. I hope it's only my mistake and not a linux-specific bug. Regards, -- Tom;Hey, lets say I have something like the following: try { // Code that throws some exception I don't know of. } catch (Exception ex) { writefln(ex.classinfo.name); // works but it's not what I need } Is there some way to get the name of the class 'ex' is instance of (the derived class and not the base class)?I'm sorry, but what *is* it that you need if not the above? import std.stdio; class DerivedException : Exception { this() { super(""); } } void main() { try { // Code that throws some exception. throw new DerivedException; } catch (Exception ex) { writefln(ex.classinfo.name); // writes "DerivedException" } } The above code writes "DerivedException" to stdout, which is the name of the most derived class ex is an instance of. Am I missing something?
Oct 30 2006
Tom wrote:== Quote from Frits van Bommel (fvbommel REMwOVExCAPSs.nl)'s article[...]Just tried it in my VMWare window: urxae ubuntu:~/tmp$ cat test.d import std.stdio; class DerivedException : Exception { this() { super(""); } } void main() { try { // Code that throws some exception. throw new DerivedException; } catch (Exception ex) { writefln(ex.classinfo.name); // writes "DerivedException" } } urxae ubuntu:~/tmp$ dmd -run test.d DerivedException urxae ubuntu:~/tmp$ uname -a GNU/Linux So that's not it either.The above code writes "DerivedException" to stdout, which is the name of the most derived class ex is an instance of. Am I missing something?No, you're right. It works here, on a WinXP machine. When I get home later, I'll test it on my Linux, where it didn't work. I hope it's only my mistake and not a linux-specific bug.
Oct 30 2006
Frits van Bommel wrote:Tom wrote:Shit! the same here. I could swear that yesterday I had code that failed to perform correctly on the topic. Today I can't reproduce it, shame on me (maybe I'm hallucinating). It'll have to be next time (hope not) :( Thanks anyway! -- Tom;== Quote from Frits van Bommel (fvbommel REMwOVExCAPSs.nl)'s article[...]Just tried it in my VMWare window: urxae ubuntu:~/tmp$ cat test.d import std.stdio; class DerivedException : Exception { this() { super(""); } } void main() { try { // Code that throws some exception. throw new DerivedException; } catch (Exception ex) { writefln(ex.classinfo.name); // writes "DerivedException" } } urxae ubuntu:~/tmp$ dmd -run test.d DerivedException urxae ubuntu:~/tmp$ uname -a GNU/Linux So that's not it either.The above code writes "DerivedException" to stdout, which is the name of the most derived class ex is an instance of. Am I missing something?No, you're right. It works here, on a WinXP machine. When I get home later, I'll test it on my Linux, where it didn't work. I hope it's only my mistake and not a linux-specific bug.
Oct 30 2006