AsDoesntThrow
Wraps an action with a try...catch of a specific exception
Source
public static Action AsDoesntThrow<T>(this Action action)
where T : Exception
{
return (() =>
{
try
{
action();
}
catch (T) {}
});
}
Example
var thisActionThrows = () => { throw new NullReferenceException() };
var thisDoesntThrow = thisActionThrows.AsDoesntThrow<NullReferenceException>();