ddd-ts-kit/domain-no-generic-error
Architecture id: domain/no-generic-error (added by this plugin). Default severity: error in recommended, error in strict.
Applies to: domain/ and application/ of a context, tests excluded.
An expected business failure has a name and a stable code that presentation maps to a status in one place. new Error("...") gives the caller a sentence to parse.
Reported
Section titled “Reported”throw new Error(...)andthrow Error(...)
Incorrect:
throw new Error('Invoice already issued');Correct:
throw new InvoiceAlreadyIssued(this.id);Options
Section titled “Options”None.
rules."domain/no-generic-error" in ddd-ts-kit.config.json set to off silences the rule, and // ddd-ts-kit-disable-next-line domain/no-generic-error -- <reason> silences one line, exactly as for ddd-ts-kit check.
Limits
Section titled “Limits”- Only the global
Erroris reported:TypeErrorand friends are left to review. - A generic error returned in a
Result(err(new Error())) or rejected (Promise.reject) is not seen.
With the CLI checker
Section titled “With the CLI checker”New with this plugin: the CLI checker has no equivalent, because the shape of a class needs a syntax tree.