Google News
logo
F# - Interview Questions
What is Exception handling in F#?
Exception handling is the standard way of handling error conditions in the .NET Framework. Thus, any .NET language must support this mechanism, including F#. An exception is an object that encapsulates information about an error. When errors occur, exceptions are raised and regular execution stops. Instead, the runtime searches for an appropriate handler for the exception. The search starts in the current function, and proceeds up the stack through the layers of callers until a matching handler is found. Then the handler is executed.
 
In addition, as the stack is unwound, the runtime executes any code in finally blocks, to guarantee that objects are cleaned up correctly during the unwinding process.
 
Example :
let ExExample a b =  
 let mutable c = 0  
 c <- (a/b)  
 printfn "Rest of the code"  
  
ExExample 10 0 
Advertisement