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
posted 13 years ago
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.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads