Created
July 7, 2017 08:41
-
-
Save nordinrahman/ad31581b313f0ff32b44f538248f1389 to your computer and use it in GitHub Desktop.
Action factory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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