failwith/failwithf are a useful operators, but they only raise exceptions of type SystemException. Here's a simple way to generalize them.
2 people like thisPosted: 12 years ago by Eirik Tsarpalis
Code by me and Nick Palladinos.
2 people like thisPosted: 12 years ago by Eirik Tsarpalis
Less-nonsense 8-line retry function that will retry a function a specified up to `maxRetries` times while it throws. After the retries, any remaining exception is allowed to propagate. Accepts a before function to allow you to wait/report when a retry is taking place
2 people like thisPosted: 10 years ago by Ruben Bartelink
When you get an exception from the F# Compiler Service, it usually does not print any useful information. But you can look at the private fields of the exception and get some more useful things out of it...
0 people like thisPosted: 9 years ago by Tomas Petricek
A first attempt at implementing symbolic exception stacktraces in computation expressions using reflection.
5 people like thisPosted: 8 years ago by Eirik Tsarpalis
A simple script to list the exceptions that can be thrown during the method invocation (both caught and uncaught).
5 people like thisPosted: 12 years ago by Natallie Baikevich
Convenience function to easily throw an argument exception with a helpful string description. Looks simple, but was hard to figure out.
1 people like thisPosted: 10 years ago by Wallace Kelly
See also https://fslang.uservoice.com/forums/245727-f-language/suggestions/6536829-implement-ocaml-s-new-match-exception-syntax
3 people like thisPosted: 9 years ago by Eirik Tsarpalis
Go and Swift have a dedicated defer keyword which allows the programmer to specify code which should run when leaving the current scope, irrespective of errors. F# supports a similar pattern with IDisposable and the use keyword, but this requires either defining a class definition or object expression and the extra syntax can make the code less expressive. This snippet defines a simple helper function called "defer" to remedy the situation.
2 people like thisPosted: 9 years ago by Anton Tcholakov