This post covers some of the lesser-known exception classes that exist. It is okay if you have never heard of these exception classes before... in fact, if you haven’t, that is probably a very, very good thing...
WTFException
The exception that is thrown when the code has encountered a genuine ‘WTF’ moment. This is usually only reserved for areas of the code that should never be reached, or indicates a state/condition that is either invalid, unexpected, or simply illogical. It can also be thrown to indicate that the developer has no idea why something is not working, and is at his wits end, or optionally at the end of some code that the developer was absolutely certain would never work.
See Also: CodeUnreachableException, ThisShouldNeverHappenException, and SpaceTimeException.
class WTFException : Exception
{
public WTFException()
: base() { }
public WTFException(string message, params object[] messageParams)
: base(string.Format(message, messageParams)) { }
public WTFException(string message, Exception innerException)
: base(message, innerException) { }
}
SpaceTimeException
The exception that is thrown when there is a serious problem with the fabric of space/time. Typically, the error message property will be empty or missing, as the actual even that caused this exception to be thrown has not yet occurred in the same timeline that your applications exists in. No attempt should be made to retrieve the InnerException object, as a black hole could result that would be almost certain to annihilate your code base, or possibly all of humanity. The only thing we can be certain of, however, is that your boss will be very cross with you and you will most likely get fired.
class SpaceTimeException : Exception
{
public SpaceTimeException()
: base() { }
public SpaceTimeException(string message, Exception innerException)
: base(message, innerException) { }
}
ArgumentInvalidException
You argument is invalid. You are wrong, your reasoning makes no logical sense, and you probably failed debate class in school. Even if your argument has some semblance of being based in logic or reality, you cannot argue with the compiler, there is no point, so quit trying.
class ArgumentInvalidException : Exception
{
public ArgumentInvalidException()
: base() { }
public ArgumentInvalidException(string message, Exception innerException)
: base(message, innerException) { }
}
CodeUnreachableExeception
This exception is thrown when the assembly executes a block of code that is unreachable. This exception should never get thrown, and is, by definition, impossible. Catching this exception is like catching a leprechaun, and should it ever happen, the CLR will ask you for three wishes.
class CodeUnreachableExeception : Exception
{
public CodeUnreachableExeception()
: base() { }
public CodeUnreachableExeception(string message, Exception innerException)
: base(message, innerException) { }
}
OutOfCoffeeExecption
This exception is thrown when a developer has ran out of coffee or sufficient motivation to complete the function or feature. The exception is thrown at the exact line that the developer got up for a coffee break and never returned.
class OutOfCoffeeExecption : Exception
{
public OutOfCoffeeExecption()
: base() { }
public OutOfCoffeeExecption(string message, Exception innerException)
: base(message, innerException) { }
}
UnknownException
This exception is not thrown because a parameter or method specified is unknown, but rather that the implementing developer did not have the knowledge to implement the feature or method you just called, and threw this exception instead as quick and dirty solution.
class UnknownException : Exception
{
public UnknownException()
: base() { }
public UnknownException(string message, Exception innerException)
: base(message, innerException) { }
}
ThisIsNotTheExceptionYouAreLookingForException
What? Oh this? Oh, this was not meant for you. Now move along...
class ThisIsNotTheExceptionYouAreLookingForException : Exception
{
/* Move along... */
}