Jump to content

Exceptions: Difference between revisions

(added JavaScript)
Line 120:
//This code is always executed after exiting the try block
}
 
==[[Standard ML]]==
===Define Exceptions===
exception MyException;
exception MyDataException of int; (* can be any first-class type, not just int *)
 
===Throw Exceptions===
fun f() = raise MyException;
fun g() = raise MyDataException 22;
 
===Catch Exceptions===
val x = f() handle MyException => 22;
val y = f() handle MyDataException x => x;
 
==[[JavaScript]]==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.