Commit a89aa3d
authored
feat(core): better cause data extraction (#17375)
Before submitting a pull request, please take a look at our
[Contributing](https://github.com/getsentry/sentry-javascript/blob/master/CONTRIBUTING.md)
guidelines and verify:
- [x] If you've added code that should be tested, please add tests.
- [x] Ensure your code lints and the test suite passes (`yarn lint`) &
(`yarn test`).
---
closes #15142
When using `ExtraErrorDataIntegration`, `error.cause` serializes with
`.toString()` which is not very informative considering the purpose of
the integration.
This PR improves `error.cause` handling in `ExtraErrorDataIntegration`
by recursing the `_extractErrorData` for a single cause depth. To match
the outer structure and provide more information the cause object is
wrapped with `[name]`.
The `.toString()` serialized data is gone now but if we are using
`LinkedErrorsIntegration` the string message will still be visible.
Since these changes are useful enough, I think more detailed
specifications (like cause recursion) could be addressed by future PRs -
open to suggestions.
**Before:**
```javascript
// error.cause was serialized as: "SyntaxError: bar"
{
TypeError: {
cause: "SyntaxError: bar" // Just toString() output
}
}
```
**After:**
```javascript
// error.cause now includes full error data extraction
{
TypeError: {
cause: {
SyntaxError: {
baz: 42,
foo: "aaaa...a...",
}
}
}
}
```1 parent 5d1e8b8 commit a89aa3d
File tree
2 files changed
+16
-4
lines changed- packages/core
- src/integrations
- test/lib/integrations
2 files changed
+16
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
119 | 124 | | |
120 | 125 | | |
121 | 126 | | |
| |||
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
| |||
0 commit comments