Skip to content

Instantly share code, notes, and snippets.

@einarwh
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/39f9d1ec870c7ae8682c to your computer and use it in GitHub Desktop.
Save einarwh/39f9d1ec870c7ae8682c to your computer and use it in GitHub Desktop.
static class CatchExtensions
{
static Func<TR> Catch<TR, TE>(
this Func<TR> f,
Func<TE, TR> h)
where TE : Exception
{
return () => {
try {
return f ();
} catch (TE ex) {
return h (ex);
};
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment