Advance Modifying Exception
Even, we could create a class to handle the exception thrown.
Create a new class named Exception
.
class MakersDefenseException : Exception
{
public MakersDefenseException()
{
}
public MakersDefenseException(string message) : base(message)
{
}
}
class OutOfBoundsException : MakersDefenseException
{
public OutOfBoundsException()
{
}
public OutOfBoundsException(string message) : base(message)
{
}
}
MakersDefenseException()
and OutofBoundsException()
is called default constructor.
This exception could be called like this.
if (!map.onMap(this))
{
throw new OutOfBoundsException(x +","+y+" outside the range");
}