View Single Post
Old 08-04-2003, 06:20 PM   #3 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,148
Belisarius is on a distinguished road
Ever wanted to give users a more explicit explaination for exceptions? Sure, you could just throw a new exception with the message, but you'd loose the stack trace associated with the original exception. Here's how you can have you cake, and eat too.

try{
// some code that throws an exception
}catch(Exception e){
Exception ex = new Exception("Something bad happened");
ex.setStackTrace(e.getStackTrace());
throw ex;
}

Just that simple!
__________________
GitS
Belisarius is offline   Reply With Quote