>Hi all
>
>Is there a mechanism to escalate the error to the global error handler if not handled by the TRY-CATCH. Or do we have to call the global error handler manually?
You can rethrow an error in the Catch and that will promote up to a higher level error handler (including ON ERROR) but if you do that you'll loose the original error information (which is lost on the Catch).
clear
ON ERROR do ErrorHandler
TRY
EVALUATE("Garbage")
CATCH TO loException
? "Exception caught"
THROW
ENDTRY
FUNCTION ErrorHandler
? Message()
? Message(1)
WAIT WINDOW "Error Handler called"
RETURN
Of course you can also fire the error handler directly and pass the exception. The problem is that unlike a traditional error handler the error information you'll retrieve when you throw out of the CATCH block is not the same as it would be if there was no try catch.
That's one of the issues with TRY/CATCH - unlike ONERROR or even class Error handlers, Try Catch unwinds the call stack so you lose the ability to easily track the code that caused the error because when Catch actually fires you're already out of that call context.
Try/Catch does:
code
calls code
calls code
catch error
where Error methods do:
code
calls code
calls code
error method
calls code (following code where error occurred)
The same applies with OnError which also is basically stacked ontop of the existing call stack.
In Web Connection when I redesigned for TRY/CATCH with version 5.0 this caused some grumbling with some folks who were very happy with the fact that their class level error handlers could collect all sorts of useful error information from the current state and that no longer works (well, there's a work around to do things the 'old' way but it's ugly).