( stackParser: StackParser, exception: Record<string, unknown>, syntheticException?: Error, isUnhandledRejection?: boolean, )
| 50 | } |
| 51 | |
| 52 | function eventFromPlainObject( |
| 53 | stackParser: StackParser, |
| 54 | exception: Record<string, unknown>, |
| 55 | syntheticException?: Error, |
| 56 | isUnhandledRejection?: boolean, |
| 57 | ): Event { |
| 58 | const client = getClient(); |
| 59 | const normalizeDepth = client?.getOptions().normalizeDepth; |
| 60 | |
| 61 | // If we can, we extract an exception from the object properties |
| 62 | const errorFromProp = getErrorPropertyFromObject(exception); |
| 63 | |
| 64 | const extra = { |
| 65 | __serialized__: normalizeToSize(exception, normalizeDepth), |
| 66 | }; |
| 67 | |
| 68 | if (errorFromProp) { |
| 69 | return { |
| 70 | exception: { |
| 71 | values: [exceptionFromError(stackParser, errorFromProp)], |
| 72 | }, |
| 73 | extra, |
| 74 | }; |
| 75 | } |
| 76 | |
| 77 | const event = { |
| 78 | exception: { |
| 79 | values: [ |
| 80 | { |
| 81 | type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error', |
| 82 | value: getNonErrorObjectExceptionValue(exception, { isUnhandledRejection }), |
| 83 | } as Exception, |
| 84 | ], |
| 85 | }, |
| 86 | extra, |
| 87 | } satisfies Event; |
| 88 | |
| 89 | if (syntheticException) { |
| 90 | const frames = parseStackFrames(stackParser, syntheticException); |
| 91 | if (frames.length) { |
| 92 | // event.exception.values[0] has been set above |
| 93 | // eslint-disable-next-line @typescript-eslint/no-non-null-assertion |
| 94 | event.exception.values[0]!.stacktrace = { frames }; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | return event; |
| 99 | } |
| 100 | |
| 101 | function eventFromError(stackParser: StackParser, ex: Error): Event { |
| 102 | return { |
no test coverage detected