MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / extractMessage

Function extractMessage

packages/browser/src/eventbuilder.ts:201–221  ·  view source on GitHub ↗
(ex: Error & { message: { error?: Error } })

Source from the content-addressed store, hash-verified

199 * In this specific case we try to extract stacktrace.message.error.message
200 */
201export 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`.

Callers 2

exceptionFromErrorFunction · 0.85

Calls 1

isWebAssemblyExceptionFunction · 0.85

Tested by

no test coverage detected