feat(tracker): fix error msg sending

This commit is contained in:
sylenien 2022-09-05 15:23:23 +02:00 committed by Delirium
parent 33c05a7dc1
commit 7f0fe77f16
2 changed files with 15 additions and 4 deletions

View file

@ -285,7 +285,8 @@ export default class API {
return
}
if (e instanceof Error) {
this.app.send(getExceptionMessage(e, [], tags, metadata))
const msg = getExceptionMessage(e, [], tags, metadata)
this.app.send(msg)
} else if (
e instanceof ErrorEvent ||
('PromiseRejectionEvent' in window && e instanceof PromiseRejectionEvent)

View file

@ -37,7 +37,8 @@ export function getExceptionMessage(
try {
stack = ErrorStackParser.parse(error)
} catch (e) {}
const method = metadata ? ExceptionWithMeta : JSException
const metaPresent = metadata || tags
const method = metaPresent ? ExceptionWithMeta : JSException
return method(
error.name,
error.message,
@ -62,7 +63,15 @@ export function getExceptionMessageFromEvent(
name = 'Error'
message = e.message
}
return JSException(name, message, JSON.stringify(getDefaultStack(e)))
const metaPresent = metadata || tags
const method = metaPresent ? ExceptionWithMeta : JSException
return method(
name,
message,
JSON.stringify(getDefaultStack(e)),
JSON.stringify(tags),
JSON.stringify(metadata),
)
}
} else if ('PromiseRejectionEvent' in context && e instanceof context.PromiseRejectionEvent) {
if (e.reason instanceof Error) {
@ -74,7 +83,8 @@ export function getExceptionMessageFromEvent(
} catch (_) {
message = String(e.reason)
}
const method = metadata ? ExceptionWithMeta : JSException
const metaPresent = metadata || tags
const method = metaPresent ? ExceptionWithMeta : JSException
return method(
'Unhandled Promise Rejection',
message,