< HTML>
Creating a Custom Exception Object
Creating a Custom Exception Object
<%!
class MyException extends Exception
{
int value;
public String toString()
{
return "MyException " + value;
}
MyException(int v)
{
value = v;
}
}
void doWork(int value) throws MyException
{
if(value == 0){
throw new MyException(value);
}
}
%>
<%
try {
doWork(3);
doWork(2);
doWork(1);
doWork(0);
}
catch (MyException e) {
out.println("Exception: " + e);
}
%>