Last active
August 29, 2015 14:01
-
-
Save eiriktsarpalis/8feb78f1f2ee7b6bfd02 to your computer and use it in GitHub Desktop.
failwith
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stackless raise | |
let inline raise (e : exn) = (# "throw" e : ^T #) | |
let inline failwith ctor = raise << ctor | |
let inline failwithf ctor fmt = Printf.ksprintf (raise << ctor) fmt | |
// 1 | |
exception SomeOtherException of string | |
with override e.Message = e.Data0 | |
failwithf SomeOtherException "exception %d" 42 | |
// 2 | |
let inline invalidOp msg = new InvalidOperationException(msg) | |
failwithf invalidOp "Invalid operation %s" "foo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment