Error reporting

Eco Lab now uses C++ standard exceptions to report errors -- the old longjmp mechanism has now gone. When you want to report an error from within your user written commands and methods, throw an object of type error, which is defined in tcl++.h. error has a convenient constructor that works a bit like printf, eg

  throw error("%d arguments is too many!",nargs);

Eco Lab will trap all exceptions in user written routines and methods, and return a TCL_ERROR result. If its an exception derived from the standard exception class (which error is), then it will place the value returned by its what() method as the result field of the TCL command. Any other caught exception will report “Unknown exception caught”.

What happens when Eco Lab traps an exception depends on exactly where it occurs -- if it occurs as a result of executing a script, the error is reported on standard output, and Eco Lab exits with a non-zero return value (useful for writing test scripts, for example). If it occurs while the GUI environment is in operation, then a dialog box pops up, offering information to debug what went wrong. If it occurs as part of the command line interpreter (ie when Eco Lab is reading its commands from standard input) then the error result is reported on standard output, and execution continues.

When the DEBUGGING flag set at make time, the error constructor will call abort(), which can be caught by a debugger.