Created
August 18, 2016 16:29
-
-
Save JustinJohnWilliams/3be692072e7cf907052ca57fc559a32c to your computer and use it in GitHub Desktop.
Casey needs moar exceptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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