Exceptions: Difference between revisions

Content deleted Content added
No edit summary
Line 47:
Aikido provides <code>try</code>, <code>catch</code> and <code>throw</code> statements.
===Catching exceptions===
There is one <code>catch</code> clause per <code>try</code> statement. The variable caught is whatever is thrown. It does not have to be a particular type, although there is a <code>System.Exception</code> class defined for system exceptions.
<lang aikido>
try {
Line 52 ⟶ 53:
process (lines)
} catch (e) {
do_somthing(e)
}
 
</lang>
 
===Throwing exceptions===
You can throw any value.
<lang aikido>
if (error) {
throw "Error"
}
 
if (something) {
throw new MyException (errorcode, a, b)
}
 
 
</lang>