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
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
Joined: Jan 14, 2010
Posts: 44
posted
0
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
This message was edited 1 time. Last update was at by Peter Aarum
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
Joined: Jan 14, 2010
Posts: 44
posted
0
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.
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
Joined: Jan 14, 2010
Posts: 44
posted
0
Thanks Roel!
I hear you and see your points. I will think more of this.