Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Saturday, December 1, 2007

java code for 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);
}
%>

No comments: