[MOAB-dev] [PATCH] scdtest.cpp: print what failed on error
Jed Brown
jed at 59A2.org
Mon Nov 30 11:47:54 CST 2009
On Mon, 30 Nov 2009 11:26:29 -0600, Jason Kraftcheck <kraftche at cae.wisc.edu> wrote:
> But I would still do something like:
>
> #define error(err) error_((err), __FILE__, __LINE__ )
In this case,
error_((err),__FILE__,__LINE__,__FUNCTION__,#err)
> a) are typesafe
The assignment to an MBErrorCode achieves the same.
> b) allow setting of break points easily, and
Agreed, though MPI_Abort also works.
> c) avoid multiple executions of an expression if the macro
> argument is an expression.
Hence saving the error code in the body of the macro.
> As you began with changing the function to a macro, and then added the
> location stuff with your second patch, it seemed that perhaps printing the
> location was not your only motivation for changing the function to a macro.
abort() prints the line number and the statement that failed, so even
the first one (admittedly a half-ass job) was a lot more useful than the
old one. Having the macro call a function is a more complete solution,
though approximately equivalent in this case. To get real benefit, it
should call via a function pointer so that you can change the error
handler at runtime.
If you want to define a standard way of handling errors within MOAB,
rather than incompletely duplicating it in each test suite, then it's
worth doing it carefully with appropriate indirection, I just wanted a
good enough error message to know that I didn't have to investigate.
Jed
More information about the moab-dev
mailing list