Home
Insert
Update snippet 'failwithf for any exception type'
Title
Passcode
Description
Works with F# 4.0 and above
Source code
let inline raisef (exnCtor : string -> #exn) fmt = Printf.kprintf (exnCtor >> raise) fmt // Before do raise <| System.ArgumentException(sprintf "Unexpected argument %A" "foo") // After do raisef System.ArgumentException "Unexpected argument %A" "foo"
Tags
failwith
failwith
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update