Forums Register Login

How to avoid client dependencies on classes of an Exception's cause?

+Pie Number of slices to send: Send
Hi!

Suppose I want to throw a chained exception over the wire. The cause of the exception is a class that might not be present on the client receiving the exception. What can I do?

1) The obvious: no chaining. Copy the message from the underlying exception into a brand new one, and loose the stacktrace (or at least log it to the serverlog).

2) Maybe I can copy the exception details from the old exception into the new one? It's just textual data, right?


Can somebody please give advice on what the usual approach is in such situations? Thanks a lot!

Regards,
Michael
+Pie Number of slices to send: Send
 

Michael:2) Maybe I can copy the exception details from the old exception into the new one? It's just textual data, right?


)]setStackTrace() method must do this for you.
You can get the stacktrace of your exception and set it to a new exception that you intend to throw to the client.
[ April 29, 2008: Message edited by: Nitesh Kant ]
+Pie Number of slices to send: Send
Thanks for the hint, I'll try that out!
Hey! You're stepping on my hand! Help me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 753 times.
Similar Threads
URLyBird : DB Interface & Exceptions: Please HELP!
Manipulating files on server
Exceptions thrown from interface provided by Sun?
Calling Ant from Java
Mutiple threads on a single reqest
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:23:00.