H3 · H30004

Preserve intentional HTTP errors in h3 handlers

Report local intentional 4xx H3 errors replaced by HTTP 500 in a catch.
H30004vite-doctor/h3requestwarnSuggestion

Run this rule

pnpm vite-doctor . --rules h3/errors/no-http-error-masking

Why it matters

Replacing an intentional client error with HTTP 500 hides the response contract from callers.

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 }) }
Copyright © 2026