Hello,
I'm trying to write a function where only two method calls (with the methods being unit -> unit) should have a certain exception handled. The behaviour should be:
- if an exception is raised the entire function ends
- the function goes on (outside of the exception handler) otherwise
At first I thought I could use a function with the statements wrapped in a try/with block and a continuation, but of course the continuation would be called from within the block...I could probably wrap the statements in a function and use a return value to signal success/failure, however that looks clunky to me compared to the following C# code, which does what I'm trying to achieve in F#.
SomeType MyMethod(string x)
{
...
try
{
foo();
bar();
}
catch(SomeException)
{
return null;
}
...
return ...;
}