Is it possible to throw an exception in server and catch and handle it in client in java

513 views Asked by At

I have a custom Run time exception i throw it in server side. What I want is to re-throw it and catch it in client side. what do I do? I have searched it but I didn't find anything. All I found were "RMI" and "GWT".

1

There are 1 answers

1
Audrius Meškauskas On BEST ANSWER

It is not possible directly, but some frameworks like RMI are capable of serializing the exception over network and then re-throwing on the client side, directly, or more often wrapped into some kind of RemoteException. This is one of the reasons why Java exceptions are serializable.

If you are using such a framework, it is possible to throw an exception on one end and get a remote exception on another end of the communication channel.