コード例:
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);
}
}
では、どのような例外をスローする必要がありますか? カスタム例外を提案する場合は、適切な名前を教えてください。