(ex: Error & { message: { error?: Error } })
| 199 | * In this specific case we try to extract stacktrace.message.error.message |
| 200 | */ |
| 201 | export function extractMessage(ex: Error & { message: { error?: Error } }): string { |
| 202 | const message = ex?.message; |
| 203 | |
| 204 | if (isWebAssemblyException(ex)) { |
| 205 | // For Node 18, Emscripten sets array[type, message] to the "message" property on the WebAssembly.Exception object |
| 206 | if (Array.isArray(ex.message) && ex.message.length == 2) { |
| 207 | return ex.message[1]; |
| 208 | } |
| 209 | return 'wasm exception'; |
| 210 | } |
| 211 | |
| 212 | if (!message) { |
| 213 | return 'No error message'; |
| 214 | } |
| 215 | |
| 216 | if (message.error && typeof message.error.message === 'string') { |
| 217 | return _INTERNAL_enhanceErrorWithSentryInfo(message.error); |
| 218 | } |
| 219 | |
| 220 | return _INTERNAL_enhanceErrorWithSentryInfo(ex); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`. |
no test coverage detected