www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - improving Error/Exception system

reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

How about having more detailed Error messages?

1) ArrayBoundError: add the bad index

current:
# extern (C) static void _d_array_bounds(char[] filename, uint line);

suggestion:
# extern (C) static void _d_array_bounds(char[] filename, uint line,
# size_t badIndex);


2) SwitchError: add the uncaught value

current:
# extern (C) static void _d_switch_error(char[] filename, uint line);

suggestion:
# extern (C) static void _d_switch_error(char[] filename, uint line,
# void* badValue, TypeInfo badValueType);

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFCUlrA3w+/yD4P9tIRAkqjAJ4mnuXPaFE9ff9xkpwyrLYlnO2ZBwCggl8/
dRDQ1hoHMGHXTbsbZQIgKNY=
=UeWN
-----END PGP SIGNATURE-----
Apr 05 2005
parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
 suggestion:
 # extern (C) static void _d_array_bounds(char[] filename, uint line,
 # size_t badIndex);

Good idea.
 suggestion:
 # extern (C) static void _d_switch_error(char[] filename, uint line,
 # void* badValue, TypeInfo badValueType);

Feels dicey. What would the switch error print or do with the values? What if the badValue was a temporary value on the stack that just became invalid because of the throw?
Apr 05 2005
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Ben Hinkle wrote:
suggestion:
# extern (C) static void _d_array_bounds(char[] filename, uint line,
# size_t badIndex);

Good idea.
suggestion:
# extern (C) static void _d_switch_error(char[] filename, uint line,
# void* badValue, TypeInfo badValueType);

Feels dicey. What would the switch error print or do with the values?

Good question.
 What if the badValue was a temporary value on the stack that just became
invalid 
 because of the throw? 

I guess it would have to make a copy of the value. An alternative would be to make _d_switch_error a template function.... Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 05 2005