Saturday, November 22, 2008

Creating a Custom Exception Object



Creating a Custom Exception Object



Creating a Custom Exception Object


<%!
class NewException extends Exception
{
int value;

public String toString()
{
return "NewException " + value;
}

NewException(int v)
{
value = v;
}
}

void doWork(int value) throws NewException
{
if(value == 0){
throw new NewException(value);
}
}
%>

<%
try {
doWork(3);
doWork(0);
} catch (NewException e) {
out.println("Exception: " + e);
}
%>


Post a Comment

  © Blogger templates Newspaper III by Ourblogtemplates.com 2008

Back to TOP