Skip to content

_on_error

bergsma edited this page Sep 26, 2014 · 5 revisions

#on_error

###Establish an error handler.

Syntax

bstatement ;

bstatement ;

Exceptions

  • None

Description

When an unrecoverable error occurs, control is transferred unconditionally to the statement following on_error. This statement is called like a method and is referred to as a handler method.

The return value of the handler method determines what action is taken after the handler executes. When the return value is TRUE, then control returns back to the statement following the point where the error occurred. If FALSE, then the program exits. If the handler completes without a return statement, then the STATUS value is assigned to the return value.

Once an error handler is used, it must be reestablished with the on_error statement to use it again. Typically, the on_error statement is called in the handler before returning. _

on_error HANDLE_ERROR();
/* .
   .
   . */

HANDLE_ERROR() {
  /* Handle an error
     .
     .
     . */
  /* Reestablish handler before returning. */
  on_error HANDLE_ERROR();
  return;
  }

_

Examples

puts "Create an example for the function 'on_error'" ;

Related Links

on_alarm
on_death
on_interrupt
on_message
on_hangup
on_pipe
on_timeout

Clone this wiki locally