• 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
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Combining Database and Remote exception

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Objects of Data can throw DatabaseException, but via RMI Remote exceptions are thrown. I combined these by having DatabaseException extend RemoteException and have methods catch or throw DatabaseExceptions and at the same time (when RMI is being used) also handling the RemoteExceptions.
By passing the exceptions on really easy and catch them all in one place and still see where they originate from. Is this approach been used by others? Is there any criticism on combining the exceptions like this?
Regards,
Pander
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This can work but be careful on how you use DatabaseException.
If it inherits from RemoteException then it should only be thrown
under similar situations/scenarios/contexts that a RemoteException would be thrown. Otherwise your code gets messy and will not make sense.
Now DatabaseException is its own class and thus is thrown for different
reasons than RemoteException, but you do not want to step to far outside
of the boundaries. For example you would not want to throw a RecordAlreadyBookedException in place of an IOException. Or wrap a
RecordAlreadyBookedException around an IOException and throw the
RecordAlreadyBookedException.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic