Exceptions: Difference between revisions
Content deleted Content added
m →[[Java]]: Use Java header instead |
m Changed over to headers |
||
Line 3:
This task is to give an example of an exception handling routine and to "throw" a new exception.
==
===Define an exception===
Foo_Error : Exception;
Line 20 ⟶ 19:
-- do something
end Call_Foo;
==
===try===
try
Line 73 ⟶ 71:
}
==
'''Compiler''': MSVS 2005
Line 137 ⟶ 135:
}
==
Forth's exception mechanism is, like most things in Forth, very simple but powerful.
CATCH captures the data and return stack pointers, then exectutes an execution token.
Line 159 ⟶ 156:
10 ['] myfun catch if drop then
==
===Define Exceptions===
exception MyException;
Line 172 ⟶ 169:
val y = f() handle MyDataException x => x;
==
===Throwing exceptions===
Line 193 ⟶ 189:
}
==
# throw an exception
Line 210 ⟶ 205:
See http://perldoc.perl.org/perlvar.html#%24EVAL_ERROR for the meaning of the special variable <tt>$@</tt>. See http://search.cpan.org/dist/Error for an advanced, object based exception handling.
==
'''Interpreter''': PHP 5.0+
Line 234 ⟶ 228:
}
==
===Throwing exceptions===
Line 260 ⟶ 253:
</pre>
==
===try-except-finally-else===
Line 279 ⟶ 271:
quux()
==
42 as custom_error
|