Skip to content

Commit 6860301

Browse files
committed
Improve profile load error handling
When an error occurs during profile load, the user is now offered the "Cancel"/"Try Again"/"Continue" options instead of just "OK".
1 parent 15a5e5e commit 6860301

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/Profiles.ahk

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ ProfileLoad(profileName, *) {
7878
return
7979
}
8080

81-
try {
82-
Loop Reg REG_KEY_PATH "\Profiles\" profileName {
81+
Loop Reg REG_KEY_PATH "\Profiles\" profileName {
82+
profileItemLoad:
83+
try {
8384
local value := RegRead()
8485

8586
switch A_LoopRegName {
@@ -126,7 +127,8 @@ ProfileLoad(profileName, *) {
126127
continue
127128

128129
local hotkeyDataMatch
129-
RegExMatch A_LoopField, "^(?P<Hotkey>.+?)%(?P<Scope>\d)%(?P<Action>\d)$", &hotkeyDataMatch
130+
RegExMatch A_LoopField, "^(?P<Hotkey>.+?)%(?P<Scope>\d)%(?P<Action>\d)$"
131+
, &hotkeyDataMatch
130132

131133
configured_hotkeys.Push({
132134
Hotkey: hotkeyDataMatch["Hotkey"],
@@ -155,18 +157,24 @@ ProfileLoad(profileName, *) {
155157
}
156158
}
157159
}
160+
} catch as err {
161+
add_log("Load Profile error: " err.Message)
162+
switch MsgBox(Format("
163+
(
164+
An error occurred whilst loading the profile '{}'.
165+
The profile is likely from an older version of EC Autoclicker.
166+
167+
Key: {}
168+
Message: {}
169+
)", profileName, A_LoopRegName, err.Message)
170+
, "Load Profile", "CancelTryAgainContinue Iconx 262144") {
171+
case "Cancel":
172+
refreshProfileSelectionLists()
173+
return
174+
case "TryAgain":
175+
goto profileItemLoad
176+
}
158177
}
159-
160-
add_log("Completed profile load")
161-
} catch as err {
162-
add_log("Load Profile error: " err.Message)
163-
MsgBox Format("
164-
(
165-
An error occurred whilst loading the profile '{}'.
166-
This is likely due to corrupt data.
167-
168-
Message: {}
169-
)", profileName, err.Message), "Load Profile", "Iconx 8192"
170178
}
171179
}
172180

0 commit comments

Comments
 (0)