【发布时间】:2012-04-07 09:32:05
【问题描述】:
假设我有一个抽象类:
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;
}
}
在这种情况下我应该抛出什么样的异常? .NET 框架中是否有指定的异常,或者我应该创建自己的自定义异常?
【问题讨论】:
-
我会抛出
ArgumentNullException但我不确定这是否完全适合。 -
YourChildClassIsStupidException异常有什么问题?
标签: .net exception inheritance abstract-class