• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception : Server side stack traces

 
Franck Tranchant
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
In order to manage my own exceptions in an EJB, i have created some classes extending Exception.
Now i would like to display proper messages to the final user, based on the messages defined in my exception classes.
Using standard try/catch, i can easily get reference to the exception that can occur during EJB execution.
The problem is that my message (myException.getMessage) is followed by the extra long message generated by the Server and starting with "Start server side stack trace:".
For exemple :
com.xx.ejb.myException: Can't find the price for this object (objId=7569, sizeCode=LI, colorCode=2)
Start server side stack trace: com.xx.ejb.myException: Can't find the price for this object (objId=7569, sizeCode=LI, colorCode=2)
at com.xx.ObjectAccess.getObjectPrice(Unknown Source)
at com.xx.ejb.ObjectBusinessService.getObjectPrice(Unknown Source)
<....>
about 20 lines here !!
<....>
Any idea about how to avoid the extra message ??
NB : I'm using BEA WebLogic Server v7.0 SP2
Thanx in advance
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick solution. One of the standard ways to pick messages are to store them in resource bundles against a key. In your exceptions pass some specific key to the constructor while throwing them.
Then when the client catches it, extract the key, look up the resource bundle and get the corresponding message and display it to the user.
That way your error messages can be internationlized as well.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Catch the exception and display appropriate message for that exception.
If a single exception has different messages then search for the string in the exception message.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!