-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(integrations): Capture error cause with captureErrorCause
in ExtraErrorData
integration
#9914
Conversation
…ExtraErrorData` integration
Why is this in the |
function _enhanceEventWithErrorData(event: Event, hint: EventHint = {}, depth: number): Event { | ||
function _enhanceEventWithErrorData( | ||
event: Event, | ||
hint: EventHint = {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hint: EventHint = {}, | |
hint: EventHint | undefined = {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional values should be at the end of the arguments list. I thought we had a rule for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter is not optional. It just takes undefined and falls back to {}
. Optional parameters are marked with a ?
like this hint?: EventHint
. Additionally, your suggestion doesn't do anything because TS already knows to allow undefined as type for parameters with default.
@@ -117,6 +125,12 @@ function _extractErrorData(error: ExtendedError): Record<string, unknown> | null | |||
extraErrorInfo[key] = isError(value) ? value.toString() : value; | |||
} | |||
|
|||
// Error.cause is a standard property that is non enumerable, we therefore need to access it separately. | |||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause | |||
if (captureErrorCause && error['cause']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (captureErrorCause && error['cause']) { | |
if (captureErrorCause && error.hasOwnProperty('cause')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot do this because cause
is a prototype (? or class field, or getter idk) and hasOwnProperty will return false even though it is there.
Based on patterns we have already established, likely no. |
Co-authored-by: Lukas Stracke <[email protected]>
…ExtraErrorData` integration (#9914) Co-authored-by: Lukas Stracke <[email protected]>
Fixes #9913
We currently have no proper way of capturing error causes in the SDK when they're not errors but serializable objects. In theory the spec allows for this so we should support it: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#providing_structured_data_as_the_error_cause