Skip to content

Commit 3749f76

Browse files
committed
Make the server-crash error fingerprint more precise
1 parent c645113 commit 3749f76

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/errors.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,22 @@ if (!DEV_MODE) {
2121
});
2222
}
2323

24-
export function logError(error: Error | string) {
24+
export function logError(error: Error | string, fingerprint?: string[]) {
2525
console.log(error);
2626

27+
const context = fingerprint
28+
? {
29+
fingerprint:[
30+
"{{ default }}",
31+
...fingerprint.filter(x => !!x)
32+
]
33+
}
34+
: undefined;
35+
2736
if (typeof error === 'string') {
28-
Sentry.captureMessage(error);
37+
Sentry.captureMessage(error, context);
2938
} else {
30-
Sentry.captureException(error);
39+
Sentry.captureException(error, context);
3140
}
3241
}
3342

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,10 @@ if (!amMainInstance) {
447447
error = new Error(`Server shutdown unexpectedly with code ${errorOrCode}`);
448448
}
449449

450-
addBreadcrumb({ category: 'server-exit', message: error.message, level: <any>'error', data: { serverRunTime } });
451-
logError(error);
450+
addBreadcrumb({
451+
category: 'server-exit', message: error.message, level: <any>'error', data: { serverRunTime }
452+
});
453+
logError(error, ['server-exit', error.message, (error as any).code?.toString() || '']);
452454

453455
showErrorAlert(
454456
'HTTP Toolkit hit an error',

0 commit comments

Comments
 (0)