示例代码:
public class ElementList
{
// some code...
public ElementList (Element owner)
{
// some code...
}
public void Add (Element e)
{
if (e == owner) // cannot add child which will be self-parent
{
throw new SomeException (); // main problem here
}
childList.Add (e);
}
}
现在我应该抛出什么样的异常?如果您建议自定义异常,请告诉我一个好名字。