[Top] [Prev] [Next] [Bottom]


[Contents] [Index]

unrescue - remove exception handler

unrescue: fn();

Description

The unrescue function removes the most recently installed handler.

Examples

This example removes the handler if normal execution occurs:

if ( rescue("an exception", e) == HANDLER) {
	# normal execution code here
	unrescue();
} else {
	# handler code here
}

The next example is a complete program that demonstrates the behavior of exception handling by executing both the normal execution code and the handler code.

implement Excep;
include "sys.m";
include "draw.m";
sys:	Sys;
	print,
	raise,
	rescue,
	rescued,
	unrescue	: import sys;
Excep: module  
{
	init:   fn(ctxt: ref Draw->Context, argv: list of 
string);
};
 
init(ctxt: ref Draw->Context, argv: list of string)
{
    sys  = load Sys Sys->PATH;
    e := ref sys->Exception;
    
    if (rescue("an exception", e) == sys->HANDLER) {
	    	print("rescue: normal execution\n");
	    	raise("an exception");
    } else {
	    	print("rescue: exceptional execution\n");
	    	print("e.name = %s\ne.mod = %s\ne.pc  = %d\n", 
	    		e.name, e.mod, e.pc);
	    	rescued(sys->ONCE, nil);
    }

# This exception will not be handled
    print ("raise: %r\n");
    raise ("an exception");
}


[Top] [Prev] [Next] [Bottom]

infernosupport@lucent.com
Copyright © 1997, Lucent Technologies, Inc.. All rights reserved.