Difference between Ex_Resume_Next & Ex_Continue

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Difference between Ex_Resume_Next & Ex_Continue

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:57 am

by JADE Kid - Ray Hidayat >> Thu, 26 Oct 2000 4:17:28 GMT

Could anyone give an explanation or example of the difference between Ex_Resume_Next & Ex_Continue (Return values of an exception handler)?

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Difference between Ex_Resume_Next & Ex_Continue

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.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Difference between Ex_Resume_Next & Ex_Continue

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:58 am

by John Porter >> Fri, 27 Oct 2000 4:18:26 GMT

For the simple answer: Ex_Continue carries on from where the exception happened; Ex_Resume_Next carries on from the method where the exception handler was armed.

Cheers,
John P


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests

cron