H3 · Request
vite-doctor/h3requestwarnSuggestion
Why it happens
Replacing an intentional client error with HTTP 500 hides the response contract from callers.
Fix
Rethrow H3 errors before converting unexpected failures to HTTP 500.
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 }) }
Preserve intentional H3 v2 errors
Before
try { throw new HTTPError({ status: 401 }) } catch { throw new HTTPError({ status: 500 }) }
After
try { throw new HTTPError({ status: 401 }) } catch (error) { if (HTTPError.isError(error)) throw error; throw new HTTPError({ status: 500 }) }
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-http-error-masking