Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(integrations): extraerrordata #4024

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions packages/integrations/src/extraerrordata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class ExtraErrorData implements Integration {
* Extract extra information from the Error object
*/
private _extractErrorData(error: ExtendedError): { [key: string]: unknown } | null {
let result = null;
// We are trying to enhance already existing event, so no harm done if it won't succeed
try {
const nativeKeys = ['name', 'message', 'stack', 'line', 'column', 'fileName', 'lineNumber', 'columnNumber'];
Expand All @@ -84,18 +83,15 @@ export class ExtraErrorData implements Integration {
if (errorKeys.length) {
const extraErrorInfo: { [key: string]: unknown } = {};
for (const key of errorKeys) {
let value = error[key];
if (isError(value)) {
value = (value as Error).toString();
}
extraErrorInfo[key] = value;
const value = error[key];
extraErrorInfo[key] = isError(value) ? (value as Error).toString() : value;
}
result = extraErrorInfo;
return extraErrorInfo;
}
} catch (oO) {
logger.error('Unable to extract extra data from the Error object:', oO);
}

return result;
return null;
}
}