J
James Harris
Although C has no support for exceptions it seems easy enough with some
programming discipline to achieve a similar effect - or at least one that
suits my purposes: basically to throw an exception at one level and catch it
higher up the call stack.
Where the exception is thrown I had in mind creating an object (i.e. a
struct) to represent some details about the exception. My question is about
what you guys would suggest to include in that object, i.e. things which are
simple in C to include and yet potentially useful. To illustrate, the call
to create the exception might be something like
excep_throw( .... );
This function would create an object to describe what was found to be wrong
and then trigger the exception handling mechanism. The mechanism is
unimportant here but what things would be good to include in the parens?
Some possibilities:
* the type of exception (an unsigned int)
* the function name (as a string?)
* __FILE__ and/or __LINE__ (if possible)
* a message string
* parameters (somehow)
Any thoughts on that? Anyone already done something similar?
James
programming discipline to achieve a similar effect - or at least one that
suits my purposes: basically to throw an exception at one level and catch it
higher up the call stack.
Where the exception is thrown I had in mind creating an object (i.e. a
struct) to represent some details about the exception. My question is about
what you guys would suggest to include in that object, i.e. things which are
simple in C to include and yet potentially useful. To illustrate, the call
to create the exception might be something like
excep_throw( .... );
This function would create an object to describe what was found to be wrong
and then trigger the exception handling mechanism. The mechanism is
unimportant here but what things would be good to include in the parens?
Some possibilities:
* the type of exception (an unsigned int)
* the function name (as a string?)
* __FILE__ and/or __LINE__ (if possible)
* a message string
* parameters (somehow)
Any thoughts on that? Anyone already done something similar?
James