posted 13 years ago
Hello all, after a long time
Is this a good approach doing like this?
Say suppose while doing a read or write on database file, there are chances of either getting a IOException or EOFException. If either of exceptions are thrown, then I want to inform client/server accordingly that
database write operation is faield and the client/server should stop immediately not to corrupt any data.
So my question is, if either exception occurs am doing the same thing and also if a generic exception "Exception" occurs will do the same thing. Is there any need to catch all three individually and throw the same exception back to client? Or is it advisable to just keep "Exception" catching there?
The main reason for catching "Exception" is that if a NullPointerException occurs then also client/server is informed. Or should I just catch only those exceptions that ARE ACTUALLY thrown in try statement?
Please comment on the approach. Thanks.
[ April 22, 2004: Message edited by: Satish Avadhanam ]

Is this a good approach doing like this?
Say suppose while doing a read or write on database file, there are chances of either getting a IOException or EOFException. If either of exceptions are thrown, then I want to inform client/server accordingly that
database write operation is faield and the client/server should stop immediately not to corrupt any data.
So my question is, if either exception occurs am doing the same thing and also if a generic exception "Exception" occurs will do the same thing. Is there any need to catch all three individually and throw the same exception back to client? Or is it advisable to just keep "Exception" catching there?
The main reason for catching "Exception" is that if a NullPointerException occurs then also client/server is informed. Or should I just catch only those exceptions that ARE ACTUALLY thrown in try statement?
Please comment on the approach. Thanks.
[ April 22, 2004: Message edited by: Satish Avadhanam ]
posted 13 years ago
Satish, EOFException extends from IOException - you will never catch it in that try-catch block
I say only catch the exceptions that are thrown. In that case, if there are any unchecked exceptions that are thrown, like ArrayIndexOutOfBoundsException, you will know about it. Otherwise, that code will just eat it up. Of course, at the last level of exception handling, you'll want to catch any exception before presenting it to the user.

I say only catch the exceptions that are thrown. In that case, if there are any unchecked exceptions that are thrown, like ArrayIndexOutOfBoundsException, you will know about it. Otherwise, that code will just eat it up. Of course, at the last level of exception handling, you'll want to catch any exception before presenting it to the user.
SCJP 1.4, SCJD 1.4, SCBCD (Preparing!)
Satish Avadhanam
Ranch Hand
Posts: 697
posted 13 years ago
Thanks Min.
OK, Thanks.
Hey Min, did you took the essay exam or still "Extremely worried"
Good Luck to you on exam
Originally posted by Min Huang:
Satish, EOFException extends from IOException - you will never catch it in that try-catch block![]()
I meant the other way around. Maybe SCJD final week(or couple of days) pressure, could'nt see it![]()
I say only catch the exceptions that are thrown. In that case, if there are any unchecked exceptions that are thrown, like ArrayIndexOutOfBoundsException, you will know about it. Otherwise, that code will just eat it up. Of course, at the last level of exception handling, you'll want to catch any exception before presenting it to the user.
OK, Thanks.
Hey Min, did you took the essay exam or still "Extremely worried"

Good Luck to you on exam

Min Huang
Ranch Hand
Posts: 100
posted 13 years ago
I was worried after taking the exam
(Why isn't there a :nervous: smiley? I'll use a combination of frown and embarassed to represent that...)
Anyways, yup, there's nothing I can do now about the exam, so... I am not worrying. I have a new exam to worry about (SCBCD)
Hey Min, did you took the essay exam or still "Extremely worried"
I was worried after taking the exam


(Why isn't there a :nervous: smiley? I'll use a combination of frown and embarassed to represent that...)
Anyways, yup, there's nothing I can do now about the exam, so... I am not worrying. I have a new exam to worry about (SCBCD)

SCJP 1.4, SCJD 1.4, SCBCD (Preparing!)
Satish Avadhanam
Ranch Hand
Posts: 697
Satish Avadhanam
Ranch Hand
Posts: 697
