catch
clause for try
SC-W1081The catch
clause allows you to recover from exceptions that were thrown in the try
block whereas the finally
clause allows you to close or free any resources that were acquired as a part of the exception handling and recovery. Having no associated catch
clause is same as not having any try-catch at all. It is therefore recommended that you either add an associated catch
clause or omit the exception handling and recovery entirely and let your code throw exceptions.
try {
// ...
} finally {
// ...
}
try {
// ...
} catch {
// ...
} finally {
// ...
}