(exception: Record<string, unknown>)
| 73 | } |
| 74 | |
| 75 | function getMessageForObject(exception: Record<string, unknown>): string { |
| 76 | if ('name' in exception && typeof exception.name === 'string') { |
| 77 | let message = `'${exception.name}' captured as exception`; |
| 78 | |
| 79 | if ('message' in exception && typeof exception.message === 'string') { |
| 80 | message += ` with message '${exception.message}'`; |
| 81 | } |
| 82 | |
| 83 | return message; |
| 84 | } else if ('message' in exception && typeof exception.message === 'string') { |
| 85 | return exception.message; |
| 86 | } |
| 87 | |
| 88 | const keys = extractExceptionKeysForMessage(exception); |
| 89 | |
| 90 | // Some ErrorEvent instances do not have an `error` property, which is why they are not handled before |
| 91 | // We still want to try to get a decent message for these cases |
| 92 | if (isErrorEvent(exception)) { |
| 93 | return `Event \`ErrorEvent\` captured as exception with message \`${exception.message}\``; |
| 94 | } |
| 95 | |
| 96 | const className = getObjectClassName(exception); |
| 97 | |
| 98 | return `${ |
| 99 | className && className !== 'Object' ? `'${className}'` : 'Object' |
| 100 | } captured as exception with keys: ${keys}`; |
| 101 | } |
| 102 | |
| 103 | function getObjectClassName(obj: unknown): string | undefined | void { |
| 104 | try { |
no test coverage detected