www.digitalmars.com         C & C++   DMDScript  

D - AssertError class needs fixing

reply imr1984 <imr1984_member pathlink.com> writes:
When is the AssertError class going to be fixed? It STILL does not override the
toString() member. This is a must for anyone who uses exception handling like
me.
Apr 07 2004
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
imr1984 wrote:
 When is the AssertError class going to be fixed? It STILL does not override the
 toString() member. This is a must for anyone who uses exception handling like
 me.

Here's the fix. Yes, I did test it, but it's on my other computer so the code below is a reconstruction (so forgive me if there's a little typo). Here's what I did: - fixed the module name to be consistent with the filename - made it rightfully a subclass of Error - called super to set the message - removed print, which consequently becomes redundant. Stewart. ---------- module std.asserterror; import std.string; class AssertError : Error { private { uint linnum; char[] filename; this(char[] filename, uint linnum) { this.linnum = linnum; this.filename = filename; super("AssertError Failure " ~ filename ~ "(" ~ std.string.toString(linnum) ~ ")"); } } } /******************************************** * Called by the compiler generated module assert function. * Builds an AssertError exception and throws it. */ extern (C) static void _d_assert(char[] filename, uint line) { //printf("_d_assert(%s, %d)\n", (char *)filename, line); AssertError a = new AssertError(filename, line); //printf("assertion %p created\n", a); throw a; } -- My e-mail is valid but not my primary mailbox. Please keep replies on on the 'group where everyone may benefit.
Apr 07 2004
parent imr1984 <imr1984_member pathlink.com> writes:
yes i know how to fix it myself, but i want the official copy of phobos to be
corrected so that when i get a new version of DMD i can just copy the correct
one from dmd.zip

In article <c51s3k$19na$1 digitaldaemon.com>, Stewart Gordon says...
imr1984 wrote:
 When is the AssertError class going to be fixed? It STILL does not override the
 toString() member. This is a must for anyone who uses exception handling like
 me.

Here's the fix. Yes, I did test it, but it's on my other computer so the code below is a reconstruction (so forgive me if there's a little typo). Here's what I did: - fixed the module name to be consistent with the filename - made it rightfully a subclass of Error - called super to set the message - removed print, which consequently becomes redundant. Stewart. ---------- module std.asserterror; import std.string; class AssertError : Error { private { uint linnum; char[] filename; this(char[] filename, uint linnum) { this.linnum = linnum; this.filename = filename; super("AssertError Failure " ~ filename ~ "(" ~ std.string.toString(linnum) ~ ")"); } } } /******************************************** * Called by the compiler generated module assert function. * Builds an AssertError exception and throws it. */ extern (C) static void _d_assert(char[] filename, uint line) { //printf("_d_assert(%s, %d)\n", (char *)filename, line); AssertError a = new AssertError(filename, line); //printf("assertion %p created\n", a); throw a; } -- My e-mail is valid but not my primary mailbox. Please keep replies on on the 'group where everyone may benefit.

Apr 07 2004