• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Michael B�ckling
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Michael B�ckling
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the hint, I'll try that out!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!