Error Handling



next up previous
Next: Memory Allocation/Garbage Collection Up: libscheme Architecture Previous: Interpreter Interface

Error Handling

The libscheme library provides rudimentary error handling support. Errors are signaled using the scheme_signal_error() function, or by failing the assertion in a SCHEME_ASSERT() expression. If the default error handler is installed by calling scheme_default_handler(), then all uncaught errors will print the error message and abort(). Errors can be caught by evaluating an expression within a SCHEME_CATCH_ERROR() form. This macro evaluates its first argument. If an error occurs during the execution, the value second argument is returned, otherwise, the value of the first expression is returned.

  obj = scheme_read (stdin);
  result = SCHEME_CATCH_ERROR (scheme_eval (obj, env), 0);
  if (result == 0)
     {
       /* error handling code */
     }
  else
     {
       scheme_write (stdout, result);
     }



Brent Benson
Mon Sep 19 16:03:14 EDT 1994