Exceptions/Catch an exception thrown in a nested call: Difference between revisions
Content added Content deleted
(+ AutoHotkey) |
m (→{{header|AutoHotkey}}: Minor indentation and casing edit) |
||
Line 134: | Line 134: | ||
Here is one way to keep track of nested errors: |
Here is one way to keep track of nested errors: |
||
<lang AutoHotkey>foo() |
<lang AutoHotkey>foo() |
||
Return |
|||
return |
|||
foo() |
foo() |
||
{ |
{ |
||
bar(0) |
bar(0) |
||
If InStr(ErrorLevel, "U0") |
|||
MsgBox caught error: U0 |
|||
bar(1) |
bar(1) |
||
If InStr(ErrorLevel, "U0") |
|||
MsgBox caught error: U0 |
|||
} |
} |
||
bar(i) |
bar(i) |
||
{ |
{ |
||
StringReplace, ErrorLevel, ErrorLevel, baz_error, ,All ; clear baz_error(s) |
StringReplace, ErrorLevel, ErrorLevel, baz_error, , All ; clear baz_error(s) |
||
If !baz(i) |
|||
ErrorLevel .= "baz_error" ; add baz_error to errorstack |
ErrorLevel .= "baz_error" ; add baz_error to errorstack |
||
} |
} |
||
baz(i) |
baz(i) |
||
{ |
{ |
||
StringReplace, ErrorLevel, ErrorLevel, U1, ,All ; clear U1 errors |
StringReplace, ErrorLevel, ErrorLevel, U1, , All ; clear U1 errors |
||
StringReplace, ErrorLevel, ErrorLevel, U0, ,All ; clear U0 errors |
StringReplace, ErrorLevel, ErrorLevel, U0, , All ; clear U0 errors |
||
If i |
|||
ErrorLevel .= "U1" ; add U1 errors to errorstack |
|||
Else |
Else |
||
ErrorLevel .= "U0" |
|||
Return 1 |
|||
return 1 |
|||
}</lang> |
}</lang> |
||