When exceptions occur, it is usually a bad idea to simply ignore them. Instead, it is better to handle them properly, or at least to log them.
function f() {
try {
doSomething();
doSomethingElse();
} catch (err) {
}
}
function f() {
try {
doSomething();
doSomethingElse();
} catch (err) {
console.log(`Exception while doing something: ${err}`);
}
}
A catch block containing no statements is not considered empty when it holds a comment explaining why the exception is ignored:
function f() {
try {
doSomething();
doSomethingElse();
} catch (err) {
// The exception is intentionally ignored
}
}
A try block guarding a single statement is allowed to leave the exception unhandled, as it clearly expresses an operation attempted on
a best-effort basis:
function f() {
try {
doSomething();
} catch (err) {
}
}