Exceptions over remote methods
Posted
by Andrei Vajna II
on Stack Overflow
See other posts from Stack Overflow
or by Andrei Vajna II
Published on 2009-04-13T10:09:42Z
Indexed on
2010/05/08
18:38 UTC
Read the original article
Hit count: 206
What are the best practices for exceptions over remote methods?
I'm sure that you need to handle all exceptions at the level of a remote method implementation, because you need to log it on the server side. But what should you do afterwards?
Should you wrap the exception in a RemoteException (java) and throw it to the client? This would mean that the client would have to import all exceptions that could be thrown. Would it be better to throw a new custom exception with fewer details? Because the client won't need to know all the details of what went wrong. What should you log on the client? I've even heard of using return codes(for efficiency maybe?) to tell the caller about what happened.
The important thing to keep in mind, is that the client must be informed of what went wrong. A generic answer of "Something failed" or no notification at all is unacceptable. And what about runtime (unchecked) exceptions?
© Stack Overflow or respective owner