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.
==[[{{header|Ada]]}}==
[[Category:Ada]]
===Define an exception===
Foo_Error : Exception;
Line 20 ⟶ 19:
-- do something
end Call_Foo;
==[[{{header|AppleScript]]}}==
[[Category:AppleScript]]
===try===
try
Line 73 ⟶ 71:
}
 
==[[{{header|C sharp|C #]]}}==
'''Compiler''': MSVS 2005
 
Line 137 ⟶ 135:
}
 
==[[{{header|Forth]]}}==
[[Category:Forth]]
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
 
==[[{{header|Standard ML]]}}==
===Define Exceptions===
exception MyException;
Line 172 ⟶ 169:
val y = f() handle MyDataException x => x;
 
==[[{{header|JavaScript]]}}==
[[Category:JavaScript]]
 
===Throwing exceptions===
Line 193 ⟶ 189:
}
 
==[[{{header|Perl]]}}==
[[Category:Perl]]
 
# 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.
 
==[[{{header|PHP]]}}==
[[Category:PHP]]
 
'''Interpreter''': PHP 5.0+
Line 234 ⟶ 228:
}
 
==[[{{header|Pop11]]}}==
[[Category:Pop11]]
 
===Throwing exceptions===
Line 260 ⟶ 253:
</pre>
 
==[[{{header|Python]]}}==
[[Category:Python]]
 
===try-except-finally-else===
Line 279 ⟶ 271:
quux()
 
==[[{{header|Raven]]}}==
[[Category:Raven]]
 
42 as custom_error