• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to handle RemoteException?

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

Any thoughts regarding extending RemoteException (or IOEx..) with my own ServiceException?

Is there something wrong with this aproach?

Cheers!
Peter
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you gonna extend RemoteException with your own ServiceException As far as I know RemoteException is already an existing exception, and Java does not support multiple inheritance, so I'm quiet confused about your question
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class ServiceException extends RemoteException { is what i mean.

/P
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So actually your ServiceException is extending RemoteException and not in the other direction

I don't think that's a good idea. Your ServiceException is-NOT-a RemoteException, so you should not use RemoteException from a design perspective.

I will describe my approach in exception handling: I created a specific service exception for each possible exception that could occur (room already booked, no rooms found,...). In my controller (at the client) I catch all the possible service exceptions (depending on the invoked method) AND a RemoteException. I rethrow a specific client-side exception (which wraps the (original) caught exception with an appropriate message for the user. So in my view I just have to catch this specific client-side exception and I can simply show the message to the user (and also log the exception, when needed).

Hope it is helpful!
Kind regards,
Roel
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roel for the reply
Glad we cleared the who is extending who issue
hmm isnt this kinda like wrapping a FileNotFoundException with say a DataAccessException in the db-layer? Ofcourse I dont extend it but ... anyway.


/P
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's the same principle. So you are hiding the implementation details, which is a thing from a design perspective. Because you can replace the existing implementation (using a database file) with a complete new implementation (using a RDBMS for example) without having to change anything besides your implementation class
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But its not good in the service-layer?
BTW I havent done this extending yet but the idea came to me when reading the other topic about RMI vs Socket.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you could do it in the service layer (as you described in a previous post), bu my remark still stands: you'll need inheritance, although your ServiceException is-NOT-a RemoteException, so from a design perspective it's not a good thing to do. But it's your choice (and don't forget to document it).
 
Peter Aarum
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roel!

I hear you and see your points. I will think more of this.

Have a great day!

/P
 
A timing clock, fuse wire, high explosives and a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic