F# Throwing Exception using Failwith Keyword
In F#, you can throw exceptions explicitly. You are allowed to throw custom exception. You can also throw exceptions by using predefined methods of Exception like Failwith and InvalidArgs.
Sorry, Age must be greater than 18 Rest of the code
F# Throwing Exception Using InvalidArg Keyword
It generates System.ArgumentException. You can throw argument type exception by using InvalidArg. Let's see an example.
System.ArgumentException: Sorry, Age must be greater than 18