(reason: unknown)
| 116 | |
| 117 | /** What a rejected promise rejected with, as message and stack. */ |
| 118 | export function describeReason(reason: unknown): { message: string; stack?: string } { |
| 119 | if (reason instanceof Error) { |
| 120 | const stack = typeof reason.stack === 'string' && reason.stack.length > 0 ? reason.stack : undefined; |
| 121 | const message = `${reason.name}: ${reason.message}`; |
| 122 | return stack === undefined ? { message } : { message, stack }; |
| 123 | } |
| 124 | return { message: safeStringify(reason) }; |
| 125 | } |
| 126 | |
| 127 | function newSessionId(): string { |
| 128 | const cryptoApi = (globalThis as { crypto?: Crypto }).crypto; |
no test coverage detected