Lets say I have an abstract class:
abstract class MyAbstract
{
protected abstract object ImplementMePlz();
public object DoSomething()
{
// Some logic here
var result = ImplementMePlz();
if (result == null)
throw new YourChildClassIsStupidException("ImplementMePlz() should never return null.");
return result;
}
}
What kind of exception should I throw in this scenario? Is there a designated exception in the .NET framework, or should I create my own custom exception?
The answer to the question “Is there a designated exception in the .NET framework?” is “no” – there is no such exception.
If I were you, I would create a custom exception.