79
F# Exception Handling using Try-With Block
F# provides try-with keyword to handle exception. Try block is used to enclose suspect code. The with block works as handler to handle the exception thrown by try block. Let’s see an Example.
Output:
Attempted to divide by zero. Rest of the code
F# Try-Finally Example if Exception is Handled
Try-Finally block is used to release resources after exception occur. Resources may be input, output, memory or network etc.
Output:
Attempted to divide by zero. Finally block is executed Rest of the code
Next TopicF# User Defined Exceptions