Should I put multiple statements in a try and then catch all possible exceptions, or should I put only one statement in the try statement?
Example:
If the method you are calling can return FooExeption() and BarException() and you want to catch both, then the first example make the most sense - quite a few API's do this, particularly ones that are higher level (as they themselves are using more things which can raise exceptions).
If you are doing two separate things then it really entirely depends on what you want the outcome to be:
If an exception in either ultimately amount to the same thing as far as your code is concerned, and you don't care about having roll anything back (or it's simple to roll back from either and you can easily do it in a single finally block - assuming the language supports this) then there is no point in having two separate try/catch blocks.
If the error types are very varied and you care what happens if the first method raises an exception (e.g. and need to do some operations to roll back) and you want to continue executing the second operation, even if the first one threw an exception, then the second approach would be more appropriate.
e.g.
try {
MaybeThrowFooException();
try {
// Will only be called as long as MaybeThrowFooException() is not thrown
MaybeThrowBarException();
} catch (BarException ex) {
}
} catch (FooException ex) {
}