If I understand what you're asking, the solution is to pass the original exception into the new exception's constructor. Java's Exception class has had this ability since JDK 1.4 with the constructor public Exception(String message, Throwable cause). The printStackTrace() method is also aware of "causes" now and will include them in the stack trace. The only problem is whether your Corba exception base class provides such a constructor. If not, you'll have to get a bit tricky with overrides.
No, that exception doesn't have a constructor which accepts another exception as a cause. But I don't think that any trickery would be required, because there's the "initCause(Throwable)" method which was also added in 1.4. So when you create the exception, you then call that method to set up the cause with the real exception which caused you to throw that one.
Joined: Oct 08, 2004
Thank you Greg, Paul.
Greg, I tried
throw new NotExist(e.getMessage(), e.getCause());
but it gave me error, constructor (string, throwable) not defined
How would I put that into code?
The other way of saying this is that you will have to come down to my level.
I can't tell you because I can't understand what you are trying to do. You have code in a catch block which catches this "NotExist" exception, and then what? You want to throw another NotExist exception? Why can't you just throw the one you already have? (And if you can, then why did you catch it in the first place?)
Or if you want to throw a new exception, what's going to go into that description?