Exceptions: Difference between revisions
Content added Content deleted
(added JavaScript) |
|||
Line 120: | Line 120: | ||
//This code is always executed after exiting the try block |
//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]]== |
==[[JavaScript]]== |