Skip to main content

Practice ยท 3 of 3

Error Boundary

Write withErrorBoundary(handler) returning a wrapped function (input) => output-object. When handler succeeds, return { status: 200, body: result }. When it throws an Error with .status, return { status: err.status, body: { error: err.message } }. Any other throw => { status: 500, body: { error: "internal error" } } โ€” the original message must NOT appear.

Difficulty: intermediate

Back to lesson: Practice: Middleware Pipeline โ€” Practice