posted 21 years ago
In my RemoteDataImpl, all methods throw RemoteException.
I am not able to convince myself about exception handling in this class.
for example. i have a three ways to implement exception handling in modify
method, but i do'nt know which one is appropriate. May be, because i do not have much experience.
1.
Comment : How would calling method's user know, whether problem is in DB layer or in RMI layer. For calling method, its ok, it needs to handle this in same way, whether it DatabaseException or RemoteException; inform user about problem and log the stacktrace or whatever. ? IMO, this is not appropriate, because user will get same message, since calling method can not find out directly through exception type real cause, it would display same message(for ex. e.getMessage()) for Remote or Database exception.
2.
Comment : This method solves problem which first method has, but it catches
RemoteException, and again create new RemoteException object(performance will go down), just for for adding the message, and wrapping it.
3.
Comment : Calling method can add its message or get the message from thrown object, and display appropriate message for the user, in addition to logging cause. However, problem with this, since calling method has same form of error handling for the exception types except displaying about the problem whether it was database problem or network problem, why should i throw two different exception types.
Which one of these , i should use in my code ?
Regards,
Akash
[ October 26, 2003: Message edited by: Jim Yingst ]