Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JustinJohnWilliams/3be692072e7cf907052ca57fc559a32c to your computer and use it in GitHub Desktop.
Save JustinJohnWilliams/3be692072e7cf907052ca57fc559a32c to your computer and use it in GitHub Desktop.
Casey needs moar exceptions
public static class Verify
{
public static void NotEmpty(string value, string parameterName)
{
if (value == string.Empty)
{
throw new ArgumentEmptyException(parameterName);
}
}
public static void NotNullOrempty(string value, string parameterName)
{
if (string.IsNullOrEmpty(value))
{
throw new ArgumentNullOrEmptyException(parameterName);
}
}
}
[Serializable]
public class ArgumentEmptyException : Exception
{
public ArgumentEmptyException() { }
public ArgumentEmptyException(string message)
: base(message) { }
public ArgumentEmptyException(string message, Exception inner)
: base(message, inner) { }
}
[Serializable]
public class ArgumentNullOrEmptyException : Exception
{
public ArgumentNullOrEmptyException() { }
public ArgumentNullOrEmptyException(string message)
: base(message) { }
public ArgumentNullOrEmptyException(string message, Exception inner)
: base(message, inner) { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment