Skip to content

Instantly share code, notes, and snippets.

@miklund
Created December 22, 2015 21:44
Show Gist options
  • Save miklund/7b6e7d39f2b29fa17a45 to your computer and use it in GitHub Desktop.
Save miklund/7b6e7d39f2b29fa17a45 to your computer and use it in GitHub Desktop.
2009-04-21 Asserting with Exceptions
# Title: Asserting with Exceptions
# Author: Mikael Lundin
# Link: http://blog.mikaellundin.name/2009/04/21/asserting-with-exceptions.html
public string Reverse(string argument)
{
argument.AssertThat(s => s != null,
"Failed assertion: Argument was null");
// ... logic ...
// return result;
}
public string Reverse(string argument)
{
if (argument == null)
throw new ArgumentNullException("argument");
// ... logic ...
// return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment