Skip to content

Fix: Improve Sentry error reporting for API failures - #2531

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/api-error-handling
Open

sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/api-error-handling

Conversation

@sentry

@sentry sentry Bot commented Sep 19, 2026

Copy link
Copy Markdown

This PR addresses issue SOLID-W3 by improving how API errors are handled and reported to Sentry.

Problem:
Previously, many API calls in lib/api.ts would throw response directly when a fetch operation returned a non-OK HTTP status. When these raw Response objects were caught by useMutation's onError handler and passed to Sentry.captureException, Sentry would report them with an unhelpful title like "Object captured as exception with keys: _bodyBlob, _bodyInit...". This made it difficult to quickly understand the nature of the API failure.

Solution:

  1. A new helper function, throwIfNotOk, has been introduced in lib/api.ts. This function checks response.ok and, if false, throws a standard Error instance with a descriptive message including the HTTP status code, status text, and URL.
  2. All 127 occurrences of if (!response.ok) throw response; across lib/api.ts have been replaced with calls to throwIfNotOk(response);. This ensures that all API failures consistently throw proper Error objects.
  3. A new unit test file, lib/__tests__/throwIfNotOk.test.ts, has been added to verify the correct behavior of the throwIfNotOk helper, ensuring it throws Error instances with the expected message content.

This change ensures that Sentry receives meaningful Error objects for API failures, leading to clearer and more actionable error reports.

Fixes SOLID-W3

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
solid-app Ignored Ignored Preview Sep 19, 2026 10:37am UTC
solid-app-staging Ignored Ignored Preview Sep 19, 2026 10:37am UTC

Request Review

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.

0 participants