javascript: fix FileUploadError stacktraces
When subclassing a JS error, most browsers include the constructor stacktrace :/ This is an issue, because: - The stacktrace is deeper than it should be - The stacktrace reaches into a polyfill for which there is not source map, which causes Sentry to infer the issue grouping from the JS file name. And the fingerprinted name changes on each release. So for each release, the stacktrace is different ; and Sentry can't group issues properly.
This commit is contained in:
parent
a583fa6391
commit
6f4075f38e
1 changed files with 10 additions and 0 deletions
|
@ -20,9 +20,19 @@ export const FAILURE_CONNECTIVITY = 'file-upload-failure-connectivity';
|
|||
export default class FileUploadError extends Error {
|
||||
constructor(message, status, code) {
|
||||
super(message);
|
||||
|
||||
this.name = 'FileUploadError';
|
||||
this.status = status;
|
||||
this.code = code;
|
||||
|
||||
// Prevent the constructor stacktrace from being included.
|
||||
// (it messes up with Sentry issues grouping)
|
||||
if (Error.captureStackTrace) {
|
||||
// V8-only
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
} else {
|
||||
this.stack = new Error().stack;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue