Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Too much DRY
public static T NullArgumentLogAndThrow<T>(this ILog log, T arg)
{
if (arg.IsNotNull()) return arg;
// get calling method
var ex = new ArgumentNullException(typeof(T).Name);
log.Fatal(new StackTrace().GetFrame(1).GetMethod().Name, ex);
log.Fatal(new StackTrace().ToString());
throw ex;
}
//...
this.requestMapper = log.NullArgumentLogAndThrow(requestMapper);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment