How to catch any exception (System.Exception) without a warning in F#?

Posted by LLS on Stack Overflow See other posts from Stack Overflow or by LLS
Published on 2011-07-07T20:20:32Z Indexed on 2012/03/30 23:29 UTC
Read the original article Hit count: 182

Filed under:

I tried to catch an Exception but the compiler gives warning: This type test or downcast will always hold

let testFail () =
    try
        printfn "Ready for failing..."
        failwith "Fails"
    with
    | :? System.ArgumentException -> ()
    | :? System.Exception -> ()

The question is: how to I do it without the warning? (I believe there must be a way to do this, otherwise there should be no warning)

Like C#

try
{
    Console.WriteLine("Ready for failing...");
    throw new Exception("Fails");
}
catch (Exception)
{
}

© Stack Overflow or respective owner

Related posts about F#