• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exceptions and RemoteException problem.

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys

I decide to use RMI
How I transport an exception from server to the client side ?
Right now I chain the cause and I use the getCause() method to get thre read cause but this lead me to some
if-instanceof statements.

The code is working but is not so nice like a try catch statements.

How you guys solve this problem?


Regards,
Mihai
 
Oliver Weikopf
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're keen on using try/catch, you can always rethrow it like this:

throw ex.getCause();

But that's not really much of an improvement since you'll have to either cast it to whatever exception it actually is or catch Throwable which is what getCause() returns.

I have opted not to chain exceptions, though, so I haven't really encountered such problems. There may be a better way I'm not aware of.
[ June 19, 2006: Message edited by: Oliver Weikopf ]
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Oliver

I use already sometihh like :

to get the real cause , but as you mention it I still need to check the type.
I have also an other ideea to encapsulte in the exceptions a type(from a typesafe enum) adn to use this but this ties my clients to musch on my middle tier.

Regards, M
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!