Add directive #ExitAppOnUnhandledException Topic is solved

Propose new features and changes
hobboy
Posts: 41
Joined: 05 Jan 2016, 09:59

Add directive #ExitAppOnUnhandledException

24 Sep 2017, 20:33

Following on from my recent post, it would be great if a directive like #ExitAppOnUnhandledException was added to AHK. The benefit of such a directive is to simplify closing the script on an unhandled exception when the script would traditionally stay open due to persistence. While there is code to enable this functionality, it requires advanced AHK knowledge so isn't easy to understand.

IMO I would like to define an unhandled Exception function that can process the Exception in my AHK script, but that seems fairly complicated. Not all information is included in the unhandled exception error message (such as the function name), so the workaround linked above doesn't give us all the important information about an exception.

My attempts at adding this functionality are here and here. Unfortunately I can't use this functionality due to a strict antivirus policy, all scripts compiled with my custom AHK version get flagged. Regular AHK versions work fine though.

I will see if I can make a pull request.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Add directive #ExitAppOnUnhandledException  Topic is solved

02 Dec 2022, 20:44

I think OnError superseded this.

Code: Select all

; AutoHotkey v1.1.29+
OnError("UnhandledException")
UnhandledException() {
    ExitApp
}

MsgBox 1
%blank% := 1
MsgBox 2

Code: Select all

; AutoHotkey v2.0-a097+
OnError (*) => ExitApp()

MsgBox 1
x := 0/0
MsgBox 2

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 21 guests