Skip to content

Instantly share code, notes, and snippets.

@nordinrahman
Created July 7, 2017 08:41
Show Gist options
  • Save nordinrahman/ad31581b313f0ff32b44f538248f1389 to your computer and use it in GitHub Desktop.
Save nordinrahman/ad31581b313f0ff32b44f538248f1389 to your computer and use it in GitHub Desktop.
Action factory
private static Action Act(Action action)
{
return () =>
{
try
{
action();
}
catch (TargetInvocationException ex)
{
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
throw ex.InnerException;
}
};
}
private static Action Act<T>(Func<T> action)
{
return () =>
{
try
{
action();
}
catch (TargetInvocationException ex)
{
ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
throw ex.InnerException;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment