Nitro · NITRO0018
Preserve intentional HTTP errors in Nitro handlers
Report local intentional 4xx H3 errors replaced by HTTP 500 in a catch.
Run this rule
pnpm vite-doctor . --framework nitro --rules nitro/h3/no-http-error-masking
Why it matters
Replacing an intentional client error with HTTP 500 hides the response contract from callers.
Recommended fix
Rethrow H3 errors before converting unexpected failures to HTTP 500.
Useful links
Example
Preserve intentional H3 errors
Before
try { throw createError({ statusCode: 401 }) } catch { throw createError({ statusCode: 500 }) }
After
try { throw createError({ statusCode: 401 }) } catch (error) { if (isError(error)) throw error; throw createError({ statusCode: 500 }) }