HomeChallengesRepsProblemsLeaderboardTake a challenge

“Something went wrong”

Two failure paths, two string messages, and nothing a caller can branch on without matching the prose. Give errors a machine-readable code and a context object — and make sure a token handed to you never survives into what gets logged.

Intermediate20 min on the clock5 graded checks · 100 pointsCode Someone Else Can Change

See alsoThe concurrency tokenThe C# version: a domain error carrying what the value is now, rather than the ORM exception.

Graded by running your code against real cases.

What you build

  • An AppError class extending Error, carrying code and details
  • USER_NOT_FOUND and SERVER_UNAVAILABLE as codes
  • Context on the error: the userId, and the status where there is one
  • A redact step so a token or password never reaches the details
  • No bare new Error left in the module
  • The nested branch flattened while you are in there

Done means

A caller can branch on a code, and nothing sensitive is in what gets logged.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. AppError is a real Error carrying a code+25Failing in a shape callers can read
  2. Secrets never reach the details+25Failing in a shape callers can read
  3. Both failure paths carry a named code+25Failing in a shape callers can read
  4. The error carries the context to debug it+15Failing in a shape callers can read
  5. The nested branch is flattened too+10Error handling

What it teaches

The rest of Code Someone Else Can Change