Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Ensure originalException has type unknown #7361

Merged
merged 1 commit into from Mar 7, 2023
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Mar 7, 2023

This used to be typed as Error | string | null which is not correct, as technically anything can be thrown. To reflect this existing reality, we have to broaden this type. Note that this could lead to problems for users that currently depend on this type, but any potential issues arising because of this would actually be valid problems that should actually be fixed in the user code (e.g. relying on error.message to be present, for example).

This also allows us to update some other types from any to unknown, which is IMHO more correct as we really just pass this through, whatever it is.

Closes #7344

This used to be typed as `Error | string | null` which is not correct, as technically _anything_ can be thrown. To reflect this existing reality, we have to broaden this type. Note that this _could_ lead to problems for users that currently depend on this type, but any potential issues arising because of this would actually be valid problems that should actually be fixed in the user code (e.g. relying on `error.message` to be present, for example).
@mydea mydea requested review from AbhiPrasad and a team March 7, 2023 09:00
@mydea mydea self-assigned this Mar 7, 2023
@mydea mydea requested review from Lms24 and removed request for a team March 7, 2023 09:00
@mydea mydea changed the title fix: Ensure originalException has type unknown feat: Ensure originalException has type unknown Mar 7, 2023
@mydea mydea changed the title feat: Ensure originalException has type unknown feat(core): Ensure originalException has type unknown Mar 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.12 KB (+0.01% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 62.55 KB (+0.05% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.76 KB (+0.02% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 55.53 KB (+0.02% 🔺)
@sentry/browser - Webpack (gzipped + minified) 20.5 KB (+0.03% 🔺)
@sentry/browser - Webpack (minified) 66.99 KB (+0.02% 🔺)
@sentry/react - Webpack (gzipped + minified) 20.53 KB (+0.03% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 48.2 KB (+0.01% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.2 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.46 KB (+0.01% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 42.87 KB (0%)
@sentry/replay - Webpack (gzipped + minified) 36.93 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 60.62 KB (-0.01% 🔽)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 54 KB (+0.01% 🔺)

@mydea mydea merged commit 9bf840a into develop Mar 7, 2023
@mydea mydea deleted the fn/error-hint branch March 7, 2023 12:13
masonmcelvain added a commit to iFixit/react-commerce that referenced this pull request Mar 10, 2023
Checks that the original exception is an `Error` before trying to access it's `message` property. In getsentry/sentry-javascript#7361 the type of `originalException` changed to unknown, because in reality anything can be thrown in JS.
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.

Improve EventHint typing to account for error-like objects
2 participants