Exceptions/Catch an exception thrown in a nested call: Difference between revisions

Content added Content deleted
(add Ruby)
(+ AutoHotkey)
Line 129: Line 129:
'''par''' clause, then all parallel the threads are terminated and the
'''par''' clause, then all parallel the threads are terminated and the
program continues in the parent thread. <!-- example needed -->
program continues in the parent thread. <!-- example needed -->
=={{header|AutoHotkey}}==
AutoHotkey has very simple support for error tracking.
The global ErrorLevel keeps track of the last error.
Here is one way to keep track of nested errors:
<lang AutoHotkey>foo()
return

foo()
{
bar(0)
if instr(ErrorLevel, "U0")
Msgbox caught error: U0
bar(1)
if instr(ErrorLevel, "U0")
Msgbox caught error: U0
}

bar(i)
{
StringReplace, ErrorLevel, ErrorLevel, baz_error, ,All ; clear baz_error(s)
if !baz(i)
ErrorLevel .= "baz_error" ; add baz_error to errorstack
}
baz(i)
{
StringReplace, ErrorLevel, ErrorLevel, U1, ,All ; clear U1 errors
StringReplace, ErrorLevel, ErrorLevel, U0, ,All ; clear U0 errors
if i
ErrorLevel .= "U1" ; add U1 errors to errorstack
Else
ErrorLevel .= "U0"
return 1
}</lang>


=={{header|C++}}==
=={{header|C++}}==