H3 · Errors
vite-doctor/h3errorserrorSuggestion
Why it happens
H3 v2 turns a thrown value that is not an Error into an unhandled 500 and drops its fields. H3 v1 passed it through createError(), so code migrated from v1 that throws { statusCode } now answers every such error with 500.
Fix
Throw an HTTPError, such as throw new HTTPError({ status: 404, message: "Not found" }) or throw HTTPError.status(404).
Example
Throw an HTTPError
Before
export default defineHandler(() => {
throw { statusCode: 404, message: "Not found" }
})
After
export default defineHandler(() => {
throw new HTTPError({ status: 404, message: "Not found" })
})
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --rules h3/errors/no-throw-plain-object