Skip to content

fix(api): set name on ApiUnavailableError and ApiRequestError (Fixes #867) - #954

Open
Lion4467cat wants to merge 1 commit into
MergeFi:mainfrom
Lion4467cat:fix/issue-867-error-names
Open

Lion4467cat wants to merge 1 commit into
MergeFi:mainfrom
Lion4467cat:fix/issue-867-error-names

Conversation

@Lion4467cat

@Lion4467cat Lion4467cat commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #867

What changed

  • Explicitly set this.name = "ApiUnavailableError" and this.name = "ApiRequestError" in both error constructors in src/lib/api.ts (matching EnvValidationError in src/lib/env.ts).
  • Added unit tests in src/lib/api.test.ts verifying .name, instanceof, stack-trace class identification, and error metadata (status, retryAfter, code).
  • Resolved upstream merge-conflict syntax remnants in src/lib/api.ts and src/lib/utils.ts so the test suite and linter execute cleanly.

Why

  • Without assigning this.name, both ApiUnavailableError and ApiRequestError inherited Error.prototype.name ("Error"), causing console.error, stack trace headers, and error-reporting grouping keys to lose the distinction between unreachable-backend fallbacks and rejected action mutations.

How to test

  • npx jest src/lib/api.test.ts --no-coverage (6 passed, 6 total)
  • npx eslint src/lib/api.ts src/lib/api.test.ts src/lib/utils.ts (0 errors, 0 warnings)

@vercel

vercel Bot commented Nov 14, 2026

Copy link
Copy Markdown

@Lion4467cat is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@Lion4467cat
Lion4467cat force-pushed the fix/issue-867-error-names branch from bb7b78a to f1cb095 Compare November 14, 2026 10:40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApiUnavailableError and ApiRequestError never set name, so both report as "Error" in logs and error reporting

1 participant