Aller au contenu

Generic Exception Thrown (ARCH3167)

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

Key typescript.logging.throw-generic-error · Severity info · Category logging

Throwing the base Error type instead of a specific domain exception forces callers into broad catch blocks. They cannot discriminate by error type.

function withdraw(account: Account, amount: number) {
if (amount > account.balance) {
throw new Error("insufficient funds");
}
account.balance -= amount;
}
class InsufficientFundsError extends Error {}
function withdraw(account: Account, amount: number) {
if (amount > account.balance) {
throw new InsufficientFundsError("insufficient funds");
}
account.balance -= amount;
}

Throw a specific domain exception that callers can catch selectively instead of base Error.