Anonymous user
Exceptions/Catch an exception thrown in a nested call: Difference between revisions
Exceptions/Catch an exception thrown in a nested call (view source)
Revision as of 20:25, 5 June 2016
, 8 years ago→{{header|REXX}}: changed/added comments and whitespace, changed indentations, changed some literals.
(→{{header|TXR}}: Update. The ! convention for opening commands is deprecated, supported in backward-compatibility mode only. Substitute new output.) |
m (→{{header|REXX}}: changed/added comments and whitespace, changed indentations, changed some literals.) |
||
Line 2,177:
While the REXX language doesn't have a ''throw'' capability ''pe se'', it does have the ability to catch exceptions (by label).
<br>This type of exception handling (in REXX) has its limitation
(the label is known global to the program, but not to external subroutines).
<lang rexx>/*REXX program
call foo /*invoke the FOO function
say 'The REXX mainline program
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
foo: call bar; call bar /*invoke BAR function twice. */
return 0 /*return a zero to the invoker. */
/*the 1st U0 in REXX program is used.*/
return -2 /*return to the invoker. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
bar: call baz
return 0 /*return a zero to the invoker. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
baz: if symbol('BAZ#')=='LIT' then baz#
if baz#==
return 0 /*return a
U1: return -1 /* " " " " " */</lang>
'''output'''
<pre>
exception U0 caught in FOO
The REXX mainline program
</pre>
|