可以說我有一個抽象類:抽象類:當子類沒有正確實現時應拋出哪個異常?
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'但我不知道這完全符合。 – Jeff 2012-03-22 19:02:42
「YourChildClassIsStupidException」異常有什麼問題? – CAbbott 2012-03-22 19:03:05