-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ignore or directly send errors to sentry
- Loading branch information
1 parent
9134c03
commit 2d7cd83
Showing
2 changed files
with
98 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
packages/app/src/systems/Error/utils/getErrorIgnoreData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
type IgnoredError = { | ||
value: string; | ||
field: 'message' | 'stack' | 'name'; | ||
comparison: 'exact' | 'partial' | 'startsWith'; | ||
/** | ||
* @description Whether to ignore the error or hide it from Report Error screen. Avoid ignoring errors that might contain sensitive information. | ||
*/ | ||
action: 'ignore' | 'hide'; | ||
}; | ||
|
||
export function getErrorIgnoreData( | ||
error: Error | undefined | ||
): IgnoredError | undefined { | ||
return IGNORED_ERRORS.find((filter) => { | ||
const errorValue = error?.[filter.field] as string | undefined; | ||
|
||
switch (filter.comparison) { | ||
case 'exact': | ||
return filter.value === errorValue; | ||
case 'startsWith': | ||
return errorValue?.startsWith(filter.value); | ||
case 'partial': | ||
return errorValue?.includes(filter.value); | ||
} | ||
}); | ||
} | ||
|
||
const IGNORED_ERRORS: IgnoredError[] = [ | ||
{ | ||
value: 'Out of sync', | ||
field: 'message', | ||
comparison: 'exact', | ||
action: 'hide', | ||
}, | ||
{ | ||
value: 'Failed to fetch', | ||
field: 'message', | ||
comparison: 'exact', | ||
action: 'hide', | ||
}, | ||
{ | ||
value: 'TypeError:', | ||
field: 'stack', | ||
comparison: 'startsWith', | ||
action: 'ignore', | ||
}, | ||
{ | ||
value: 'NotFoundError', | ||
field: 'name', | ||
comparison: 'exact', | ||
action: 'hide', | ||
}, | ||
{ | ||
value: 'The browser is shutting down.', | ||
field: 'message', | ||
comparison: 'partial', | ||
action: 'hide', | ||
}, | ||
{ | ||
value: 'Error fetching asset from db', | ||
field: 'message', | ||
comparison: 'partial', | ||
action: 'hide', | ||
}, | ||
{ | ||
value: 'Cannot read properties of undefined', | ||
field: 'message', | ||
comparison: 'partial', | ||
action: 'hide', | ||
}, | ||
{ | ||
value: 'Params are required', | ||
field: 'message', | ||
comparison: 'partial', | ||
action: 'hide', | ||
}, | ||
]; |