JavaScript · Error Handling · Senior · Architecture
Design an error-handling strategy for a multi-team JS platform (shared client SDK, web apps, and Node workers).
Short Interview Answer
Standardize error shapes/codes, layer-specific handling rules, telemetry taxonomy, and privacy redaction; enforce via shared libraries and lint.
Detailed Explanation
Define a shared `AppError` with `code`, `status`, `retryable`, `cause`, and safe `userMessage`. Map HTTP and domain failures once in the SDK. Apps: translate codes to UX; never parse free-text. Workers: retry policies based on `retryable`, dead-letter after N. Telemetry: severity, code, fingerprinting, PII scrubbing. Ban empty catches via lint. Provide playbooks for incidents. Version error contracts. Decide exceptions vs Result types per language boundary (TS). Leadership includes training and review checklists so teams don't invent incompatible schemes.
Interview Tip
Talk contracts + enforcement, not only try/catch.
Common Mistake
Every team inventing different error JSON shapes.