Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
🐛 Fix error serialization
Browse files Browse the repository at this point in the history
Related: #28
  • Loading branch information
smolijar committed Nov 22, 2019
1 parent c296c49 commit 0f7f3a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ class SentryTransformStream extends Transform {
scope.setLevel(PINO_TO_SENTRY[obj.level]);
scope.setExtras(obj);
if (obj.stack) {
captureException(obj);
const error = new Error(obj.message);
error.message = obj.message;
error.stack = obj.stack;
error.name = obj.name;
captureException(error);
} else {
captureMessage(obj.message || obj);
}
Expand Down
6 changes: 1 addition & 5 deletions src/tests/sentry-mocked.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,7 @@ describe('sentry mocked', () => {
expect(captureException).toHaveBeenCalledTimes(1);
expect(captureMessage).not.toHaveBeenCalled();
expect(captureException.mock.results[0].value).toMatchObject({
data: {
level: 50,
message: expect.any(String),
stack: expect.any(String),
},
data: expect.any(Error),
scope: {
level: 'error',
},
Expand Down

0 comments on commit 0f7f3a7

Please sign in to comment.