Just Code‎ > ‎

F# - Basic Try catch pattern

posted Dec 29, 2011, 2:48 PM by Peter Henell   [ updated Jan 25, 2012, 5:15 AM ]
The basic try catch pattern is very neat. You only need to match your expected exception type and you are done!

let GetNum x =
    try
        let res = 100 / x
        res
    with
    | :? System.DivideByZeroException -> -1
    | :? System.OverflowException -> -2
Comments