Skip to main content

Practice ยท 3 of 3

Uniform Error Shaper

Write apiError(status, message, field?) returning { status, body } where body is { error: { message, field? } } โ€” field only included when provided. Write fromZod(issues) mapping an array of { path, message } into the details array shape [{ field, message }] (path is a string like "dueDate").

Difficulty: intermediate

Back to lesson: Practice: REST Resource Design โ€” Practice