Skip to content

Instantly share code, notes, and snippets.

@SzymonPobiega
Created April 11, 2012 11:59
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 SzymonPobiega/2358879 to your computer and use it in GitHub Desktop.
Save SzymonPobiega/2358879 to your computer and use it in GitHub Desktop.
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