All challenges

TypeScript · medium

Swallow the 500

#29

Situation

The API helper eats every failure and returns null. The UI draws an empty success state while ops pages a real 500. On failure, fetchOrder must reject: do not launder errors into silence.

Objective

Success still returns the order; failures must surface, not become silent null. fetchOrder(1){ id: 1 }. fetchOrder(500) rejects with a message containing ORDER_500.

The repo at start

workspace/
└── src/
    └── api.ts   (catch → null; UI shows "success")

Checks you will turn green

  • exports fetchOrder
  • fetchOrder(1) returns the order
  • fetchOrder(500) rejects with ORDER_500

Concepts

errorsasync-await

Play it in your terminal

With sharpen installed, this command opens exactly this challenge in your local arena:

sharpen 29

First time? The full install is right below.

How to play

  1. 1 Install Claude Code if you do not have it yet: claude.com/claude-code
  2. 2 Install sharpen from npm:
    npm install -g @juanwmedia/sharpen
  3. 3 Then launch it; the arena opens in your browser:
    sharpen 29
  4. or Or try it without installing anything:
    npx @juanwmedia/sharpen 29
  5. 4 And to update when a new version ships:
    sharpen update