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

Function extractType

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

Source from the content-addressed store, hash-verified

180 * Usually, this is the `name` property on Error objects but WASM errors need to be treated differently.
181 */
182export function extractType(ex: Error & { message: { error?: Error } }): string | undefined {
183 const name = ex?.name;
184
185 // The name for WebAssembly.Exception Errors needs to be extracted differently.
186 // Context: https://github.com/getsentry/sentry-javascript/issues/13787
187 if (!name && isWebAssemblyException(ex)) {
188 // Emscripten sets array[type, message] to the "message" property on the WebAssembly.Exception object
189 const hasTypeInMessage = ex.message && Array.isArray(ex.message) && ex.message.length == 2;
190 return hasTypeInMessage ? ex.message[0] : 'WebAssembly.Exception';
191 }
192
193 return name;
194}
195
196/**
197 * There are cases where stacktrace.message is an Event object

Callers 2

exceptionFromErrorFunction · 0.85

Calls 1

isWebAssemblyExceptionFunction · 0.85

Tested by

no test coverage detected