Page 1 of 1
Jade Exception handlers
Posted: Fri Aug 07, 2009 1:25 pm
by ConvertFromOldNGs
by Tim M >> Mon, 26 Jan 2009 0:21:57 GMT
Is it possible to have an exception handler that does a thing like Ex_Abort_Action but instead of stripping the entire stack it only takes upto and including the method that armed the exception handler off the stack. A lot of the time I am writing wrapper methods that arm an exception handler that does Ex_Resume_Next and calling only one other method.
Re: Jade Exception handlers
Posted: Fri Aug 07, 2009 1:25 pm
by ConvertFromOldNGs
by Dean Cooper >> Mon, 26 Jan 2009 8:12:33 GMT
No, there isn't an exception handler return code that does that. The way to achieve it is with a wrapper method, as you've pointed out. It's been suggested a few times in the past that we provide an equivalent to inline try/catch blocks to enable this sort of thing. It would be interesting to know how popular a suggestion this is, compared to a new exception return code that cuts the stack back up to an including the arming method.
Dean.
Re: Jade Exception handlers
Posted: Fri Aug 07, 2009 1:25 pm
by ConvertFromOldNGs
by Murray Symon >> Mon, 26 Jan 2009 8:40:02 GMT
I, for one, would appreciate a Delphi-like try/catch block.
At present the approach can require 3 methods to implement (including the exception handler) which can be overkill and is not always warranted due to the additional complexity. So often guard code get used instead. However, the prospect of a new return type may also help (something to think about ...).
Murray.
Re: Jade Exception handlers
Posted: Fri Aug 07, 2009 1:25 pm
by ConvertFromOldNGs
by Tim M >> Mon, 26 Jan 2009 10:55:06 GMT
I was trying to see how close I could get there on my own but it was messy passing in a string to Object::try that got compiled transiently so no syntax colour/reporting and slow. Something like this would be nice:
vars
i : Integer;begin
try
i := 1 div 0;
catch(UserInterfaceException)
//optional
catch(LockException)
//optional
catch(Exception)
//default Exception catch must be included
endTryCatch;
epilog
//Jade doesn't need finally block because it already has epilog
end;
Re: Jade Exception handlers
Posted: Fri Aug 07, 2009 1:25 pm
by ConvertFromOldNGs
by John Munro >> Tue, 26 May 2009 3:14:38 GMT
Either option would solve the problem for me - I put in an NFS (contact #27072) years ago for try/catch, but I've recently also submitted an NFS (contact #51171) for a new exception handler return code because I imagine it could be implemented faster than new syntax.
John