Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:58 am
by Craig Shearer >> Thu, 26 Oct 2000 19:12:23 GMT
Well, the JADE documentation is reasonably clear on this, but here goes anyway:
When you return Ex_Resume_Next from an exception handler, control passes back to the method that armed the exception handler, with execution continuing after the statement that resulted in the exception being generated.
Here's a simple example:
updateCustomer(cust: Customer input);
begin
// arm the exception handler
on Exception do handleException(exception);
setCustomerName(cust, "test");
write "after setting customer's name";
end;
setCustomerName(cust: Customer; name: String);
begin
cust.setName(name);
write cust.name;
end;
Let's say that cust is null. the setCustomerName method will get an exception when it tries to call setName on a null customer object. The exceptionHandler method will be called.
If this exception handler returns Ex_Resume_Next then execution continues back in the method that armed the handler: immediately after the setCustomerName call.
If the exception handler returns Ex_Continue then execution would continue in the setCustomerName method, as if nothing untoward had happened.
Note however, that only a few exception types may be continued. Most cannot be continued which makes sense - most are fairly severe errors that must be correctly handled because it wouldn't be safe to continue execution as if nothing had happened.
One thing to note is that if you arm the exception handler in the same method that encounters the exception then doing an Ex_Resume_Next will be equivalent to doing an Ex_Continue anyway. You then need to have some method of detecting that an exception has occurred. Usually, you'd set a flag inside your exception handler which you'd test in your calling methods.
Hope this helps...
Craig.