H3 · H30014
Pass createError() an object, not a status number
Flags createError() called with a bare status code, such as createError(404).
Run this rule
pnpm vite-doctor . --rules h3/errors/no-numeric-create-error
Why it matters
createError() reads the status from an object or a message string. A number is neither, so createError(404) builds a 500 error in both H3 v1 and v2, and clients get a server error instead of the intended status.
Recommended fix
Pass the status in an object, such as createError({ status: 404 }), or use HTTPError.status(404) in H3 v2.
Useful links
Example
Pass the status in an object
Before
export default defineHandler(() => {
throw createError(404)
})
After
export default defineHandler(() => {
throw createError({ status: 404, message: "Not found" })
})