Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 15, 2025

  • Explore repository structure and understand ErrorBoundary implementation
  • Verify current behavior: non-Error objects (null, string, number, object) are NOT converted to Error instances
  • Update getDerivedStateFromError to convert non-Error objects to Error instances
  • Update componentDidCatch to convert non-Error objects for onError callback
  • Create convertToError helper function for consistent conversion logic
  • Add comprehensive tests to verify non-Error objects are properly converted in fallback props
  • Add tests to verify onError callback receives Error instances
  • Update type signatures to accept any type for error parameters (following Sentry's approach)
  • Add explanatory comments referencing Sentry's implementation
  • Run all tests to ensure no regressions (186 tests passed)
  • Run linter and type checker (no new errors)
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: If non error object thrown from children, ErrorBoundary should assert it as Error object in runtime</issue_title>
<issue_description>### Package Scope

@suspensive/react

Description

If non error object thrown from children, ErrorBoundary should assert it as Error object in runtime

Possible Solution

No response

etc.

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #1785


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@vercel
Copy link

vercel bot commented Oct 15, 2025

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

Project Deployment Preview Comments Updated (UTC)
v2.suspensive.org Ready Ready Preview Comment Oct 15, 2025 9:28am
v3.suspensive.org Ready Ready Preview Comment Oct 15, 2025 9:28am
visualization.suspensive.org Ready Ready Preview Comment Oct 15, 2025 9:28am

@changeset-bot
Copy link

changeset-bot bot commented Oct 15, 2025

⚠️ No Changeset found

Latest commit: 109a5c0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@manudeli
Copy link
Member

@coauthors
Copy link

coauthors bot commented Oct 15, 2025

People can be co-author:

Candidate Reasons Count Add this as commit message
@Copilot #1786 1 Co-authored-by: Copilot <[email protected]>
@manudeli #1786 (comment) 1 Co-authored-by: manudeli <[email protected]>

Copilot AI changed the title [WIP] Fix ErrorBoundary to assert non-error objects as Error feat(react): Convert non-Error objects to Error instances in ErrorBoundary Oct 15, 2025
Copilot AI requested a review from manudeli October 15, 2025 09:13
Copilot finished work on behalf of manudeli October 15, 2025 09:13
Copy link
Contributor Author

Copilot AI commented Oct 15, 2025

@copilot ref: https://github.com/getsentry/sentry-javascript/blob/develop/packages/react/src/error.ts#L55-L71

Updated the implementation to follow Sentry's approach. Changed type signatures for getDerivedStateFromError and componentDidCatch to accept any type instead of Error, acknowledging that these methods can be invoked with non-error objects. Added comments referencing the Sentry implementation and GitHub issue #6167. (commit: short hash will be in next message)

@copilot ref: https://github.com/getsentry/sentry-javascript/blob/develop/packages/react/src/error.ts#L55-L71

Updated the implementation to follow Sentry's approach. Changed type signatures for getDerivedStateFromError and componentDidCatch to accept any type instead of Error, acknowledging that these methods can be invoked with non-error objects. Added comments referencing the Sentry implementation and GitHub issue #6167. (109a5c0)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

If you need me to access, download, or install something from one of these locations, you can either:

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.

[Feature]: If non error object thrown from children, ErrorBoundary should assert it as Error object in runtime

2 participants