Handling Exceptions with case statement - convert Exception to int value

Hi,

I'm developing a web app, with servlets.

I'm catching Exceptions in my servlets, for example I would like a user to insert data into a form. If the data cannot be converted into a integer value a java.lang.NumberormatException is thrown.

I would like to catch this and then create a message giving a more specific clue to what happened. Unfortunatly it's possible that other exceptions could be caught, so I want to be able to check which type of Exception has been caught.

I started writing a getErrorMessage(int Code) class. The method has a case statement which just checks the code and return the appropriate message.

This worked well for SQL exceptions as they provide a getErrorCode method. But I was wondering is there any way to convert other Exceptions such as

java.lang.NumberormatException into an integer value?

Cheers

[887 byte] By [devdaveja] at [2007-10-2 16:38:42]
# 1
Exceptions have their types (classes) and messages (and maybe an embedded exception). That is, they have much richer internal status then an integer. Why should they be "converted" to integers? FLAME onGone are the days of good old errno. FLAME off
BIJ001a at 2007-7-13 17:46:31 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...