Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
return event;
}
// If none of previous checks were valid, then it means that it's not:
// - an instance of DOMError
// - an instance of DOMException
// - an instance of Event
// - an instance of Error
// - a valid ErrorEvent (one with an error property)
// - a plain Object
//
// So bail out and capture it as a simple message:
event = eventFromString(exception as string, syntheticException, options);
addExceptionTypeValue(event, `${exception}`, undefined);
addExceptionMechanism(event, {
synthetic: true,
});
return event;
}
event = eventFromString(message, syntheticException, options);
addExceptionTypeValue(event, message);
return event;
}
if (isError(exception as Error)) {
// we have a real Error object, do nothing
event = eventFromStacktrace(computeStackTrace(exception as Error));
return event;
}
if (isPlainObject(exception) || isEvent(exception)) {
// If it is plain Object or Event, serialize it manually and extract options
// This will allow us to group events based on top-level keys
// which is much better than creating new group when any key/value change
const objectException = exception as {};
event = eventFromPlainObject(objectException, syntheticException, options.rejection);
addExceptionMechanism(event, {
synthetic: true,
});
return event;
}
// If none of previous checks were valid, then it means that it's not:
// - an instance of DOMError
// - an instance of DOMException
// - an instance of Event
// - an instance of Error
// - a valid ErrorEvent (one with an error property)
// - a plain Object
//
// So bail out and capture it as a simple message:
event = eventFromString(exception as string, syntheticException, options);
addExceptionTypeValue(event, `${exception}`, undefined);
.then(event => {
addExceptionTypeValue(event, undefined, undefined);
addExceptionMechanism(event, mechanism);
resolve({
...event,
event_id: hint && hint.event_id,
});
})
.then(null, reject),
scope.addEventProcessor((event: SentryEvent) => {
const processedEvent = { ...event };
if (options.mechanism) {
addExceptionTypeValue(processedEvent, undefined, undefined);
addExceptionMechanism(processedEvent, options.mechanism);
}
processedEvent.extra = {
...processedEvent.extra,
arguments: normalize(args, 3),
};
return processedEvent;
});
public eventFromException(exception: any, hint?: EventHint): PromiseLike {
const syntheticException = (hint && hint.syntheticException) || undefined;
const event = eventFromUnknownInput(exception, syntheticException, {
attachStacktrace: this._options.attachStacktrace,
});
addExceptionMechanism(event, {
handled: true,
type: 'generic',
});
event.level = Severity.Error;
if (hint && hint.event_id) {
event.event_id = hint.event_id;
}
return SyncPromise.resolve(event);
}
/**
}
const client = currentHub.getClient();
const event = isPrimitive(error)
? self._eventFromIncompleteOnError(msg, url, line, column)
: self._enhanceEventWithInitialFrame(
eventFromUnknownInput(error, undefined, {
attachStacktrace: client && client.getOptions().attachStacktrace,
rejection: false,
}),
url,
line,
column,
);
addExceptionMechanism(event, {
handled: false,
type: 'onerror',
});
currentHub.captureEvent(event, {
originalException: error,
});
if (self._oldOnErrorHandler) {
return self._oldOnErrorHandler.apply(this, arguments);
}
return false;
};
return self._oldOnUnhandledRejectionHandler.apply(this, arguments);
}
return true;
}
const client = currentHub.getClient();
const event = isPrimitive(error)
? self._eventFromIncompleteRejection(error)
: eventFromUnknownInput(error, undefined, {
attachStacktrace: client && client.getOptions().attachStacktrace,
rejection: true,
});
event.level = Severity.Error;
addExceptionMechanism(event, {
handled: false,
type: 'onunhandledrejection',
});
currentHub.captureEvent(event, {
originalException: error,
});
if (self._oldOnUnhandledRejectionHandler) {
return self._oldOnUnhandledRejectionHandler.apply(this, arguments);
}
return true;
};