[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to clear Error handled by Application_Error()


Le 20/01/2026 à 22:28, Lee a écrit :
I have the following code in a GUI application:

[code]
' Gambas class file

Static Public Sub Application_Error()

   Message.Error(Error.Text & "\n\nMust abort.", "Okay")
   Error.Clear
   Debug Error.Code, Error.Text

End

Public Sub Button1_Click()

   Message.Title = "Button 1"
   Error.Raise("oops1") 'Line 14

End
[/code]

Once the user is informed about the critical error, there is no need for it anymore. However, I can't figure out how to cancel the Error event. "Stop Event" doesn't do it. Error.Clear does clear the error code and text, but the application still stops due to the exception at Line 14.

I've found I can use Application_Log() for what I need, but for future reference, is it possible to stop an error event that is handled in Application_Error()?



No. The only way to prevent an error is CATCH and TRY.

'Application_Error()' is just there for printing the error elsewhere, after it has been raised. So it's too late, you cannot "unraise" it.

Regards,

--
Benoît Minisini.


References:
How to clear Error handled by Application_Error()Lee <t.lee.davidson@xxxxxxxxx>