|
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!
|