Aller au contenu

Empty Catch Block (ARCH3150)

Ce contenu n’est pas encore disponible dans votre langue.

Key typescript.logging.empty-catch-block · Severity warning · Category logging

A catch block with an empty body (or only comments) silently swallows the exception. This hides bugs and lets faulty state continue unnoticed.

function loadConfig(path: string): Config {
try {
return JSON.parse(readFileSync(path, "utf8"));
} catch {
// ignore
}
return defaultConfig;
}
function loadConfig(path: string): Config {
try {
return JSON.parse(readFileSync(path, "utf8"));
} catch (err) {
logger.warn("config unreadable, using default", { path, err });
return defaultConfig;
}
}

At minimum log the exception or rethrow it; never swallow it silently.