Zum Inhalt springen

Swallowed Exception (ARCH3151)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key typescript.logging.swallowed-exception · Severity warning · Category logging

A handler that catches an exception and silently discards it - returning null/false or ignoring it - hides the failure. This differs from a strictly empty block: there is a body, but the exception is lost.

function getUser(id: string): User | null {
try {
return repository.findById(id);
} catch (err) {
return null;
}
}
function getUser(id: string): User | null {
try {
return repository.findById(id);
} catch (err) {
logger.error("failed to load user", { id, err });
return null;
}
}

Log the caught exception or rethrow it before returning a fallback value.