Is it good practice to have more than one try{} catch{} statement per method?
Is it good practice to have more than one try{} catch{} statement per method?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In my point of view it is good practice to have each method handle only a single task. As such you’ll rarely need to have multiple try/catch blocks within a single method. However, I don’t see any problems with it.
As Lisa pointed out you should catch specific exceptions and only catch the exceptions the method can actually handle.