Jump to content

Exceptions: Difference between revisions

m
Line 973:
 
'''Defining exceptions'''
<lang elena>class MyException :: Exception
{
constructor new()
<= new:"MyException raised".;
}</lang>
 
'''Throw exceptions'''
<lang elena>foo()
{
[
MyException .new; raise().raise()
}
]
</lang>
 
'''Catching exceptions'''
<lang elena>try(o foo)
{
ono.foo(MyException e)
}
[
catch(MyException e)
// handle exceptions of type MyException and derived
{
]
// handle exceptions of type MyException and derived
}</lang>
 
'''Catching any exception'''
<lang elena>o .foo() | if(:(e)
{
[
// handle any type of exception not handled by above catches
].};</lang>
 
=={{header|Erlang}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.