decord/source/1007_exceptionFromError.js

351 lines
11 KiB
JavaScript
Raw Normal View History

2026-07-20 16:05:17 +00:00
// Module ID: 1007
2026-07-25 08:10:48 +00:00
// Function ID: 11004
2026-07-20 16:05:17 +00:00
// Name: exceptionFromError
2026-07-23 10:11:24 +00:00
// Dependencies: [794]
2026-07-20 16:05:17 +00:00
// Module 1007 (exceptionFromError)
2026-07-23 10:11:24 +00:00
const require = arg1;
const dependencyMap = arg6;
2026-07-20 16:05:17 +00:00
function exceptionFromError(arg0, name) {
const arr = parseStackFrames(arg0, name);
let obj = { type: extractType(name), value: extractMessage(name) };
if (arr.length) {
obj = { frames: arr };
obj.stacktrace = obj;
}
let tmp = undefined === obj.type;
if (tmp) {
tmp = "" === obj.value;
}
if (tmp) {
obj.value = "Unrecoverable error caught";
}
return obj;
}
function eventFromPlainObject(arg0, error, arg2, isUnhandledRejection) {
2026-07-23 10:11:24 +00:00
let obj = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
const client = obj.getClient();
let normalizeDepth;
if (null != client) {
normalizeDepth = client.getOptions().normalizeDepth;
}
let tmp3;
const keys = Object.keys();
if (keys !== undefined) {
while (keys[tmp] !== undefined) {
let tmp13 = tmp5;
let _Object = Object;
if (!hasOwnProperty.call(error, tmp5)) {
continue;
} else {
let tmp6 = error[tmp5];
let _Error = Error;
let tmp7 = tmp6;
tmp3 = tmp6;
if (tmp6 instanceof Error) {
break;
}
}
continue;
}
}
obj = {};
2026-07-23 10:11:24 +00:00
let obj3 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
obj.__serialized__ = obj3.normalizeToSize(error, normalizeDepth);
obj = {};
const obj1 = {};
if (tmp3) {
const items = [exceptionFromError(arg0, tmp3)];
obj1.values = items;
obj.exception = obj1;
obj.extra = obj;
return obj;
} else {
const obj2 = {};
if (obj8.isEvent(error)) {
let str = error.constructor.name;
} else {
str = "Error";
if (isUnhandledRejection) {
str = "UnhandledRejection";
}
}
obj2.type = str;
obj3 = { isUnhandledRejection };
obj2.value = getNonErrorObjectExceptionValue(error, obj3);
const items1 = [obj2];
obj1.values = items1;
obj.exception = obj1;
obj.extra = obj;
if (arg2) {
const arr2 = parseStackFrames(arg0, arg2);
if (arr2.length) {
const obj4 = { frames: arr2 };
obj.exception.values[0].stacktrace = obj4;
}
}
return obj;
}
}
function eventFromError(arg0, error) {
let obj = {};
obj = {};
const items = [exceptionFromError(arg0, error)];
obj.values = items;
obj.exception = obj;
return obj;
}
function parseStackFrames(arg0, stacktrace) {
let num = 0;
if (stacktrace) {
num = 0;
if (regex.test(stacktrace.message)) {
num = 1;
}
}
let num2 = 0;
if ("number" === typeof stacktrace.framesToPop) {
num2 = stacktrace.framesToPop;
}
return arg0(stacktrace.stacktrace || stacktrace.stack || "", num, num2);
}
function isWebAssemblyException(message) {
let tmp = "undefined" !== typeof globalThis.WebAssembly;
if (tmp) {
tmp = undefined !== globalThis.WebAssembly.Exception;
}
if (tmp) {
tmp = message instanceof globalThis.WebAssembly.Exception;
}
return tmp;
}
function extractType(name) {
name = undefined;
if (null != name) {
name = name.name;
}
let tmp2 = name;
if (!name) {
tmp2 = name;
if (isWebAssemblyException(name)) {
let str2 = "WebAssembly.Exception";
if (name.message) {
const _Array = Array;
str2 = "WebAssembly.Exception";
if (Array.isArray(name.message)) {
str2 = "WebAssembly.Exception";
if (2 == name.message.length) {
str2 = name.message[0];
}
}
}
tmp2 = str2;
}
}
return tmp2;
}
function extractMessage(message) {
if (null != message) {
let error = message.message;
}
if (isWebAssemblyException(message)) {
const _Array = Array;
let str4 = "wasm exception";
if (Array.isArray(message.message)) {
str4 = "wasm exception";
if (2 == message.message.length) {
str4 = message.message[1];
}
}
let str = str4;
} else {
str = "No error message";
if (error) {
if (!error.error) {
2026-07-23 10:11:24 +00:00
let result = require(794) /* registerSpanErrorInstrumentation */._INTERNAL_enhanceErrorWithSentryInfo(message);
const obj = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
error = error.error;
2026-07-23 10:11:24 +00:00
result = require(794) /* registerSpanErrorInstrumentation */._INTERNAL_enhanceErrorWithSentryInfo(error);
const obj2 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
}
return str;
}
function eventFromUnknownInput(arg0, error, arg2, arg3, isUnhandledRejection) {
2026-07-23 10:11:24 +00:00
let obj = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
if (obj.isErrorEvent(error)) {
if (error.error) {
return eventFromError(arg0, error.error);
}
}
2026-07-23 10:11:24 +00:00
let obj1 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
if (!obj1.isDOMError(error)) {
if (!obj3.isDOMException(error)) {
if (obj4.isError(error)) {
let tmp14 = eventFromError(arg0, error);
} else {
if (!obj5.isPlainObject(error)) {
if (!obj6.isEvent(error)) {
tmp14 = eventFromString(arg0, error, arg2, arg3);
const _HermesInternal = HermesInternal;
2026-07-23 10:11:24 +00:00
const result = require(794) /* registerSpanErrorInstrumentation */.addExceptionTypeValue(tmp14, "" + error, undefined);
const obj7 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
obj = { synthetic: true };
2026-07-23 10:11:24 +00:00
const result1 = require(794) /* registerSpanErrorInstrumentation */.addExceptionMechanism(tmp14, obj);
const obj8 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
obj6 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
const tmp25 = eventFromPlainObject(arg0, error, arg2, isUnhandledRejection);
2026-07-23 10:11:24 +00:00
obj5 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
obj = { synthetic: true };
2026-07-23 10:11:24 +00:00
const result2 = require(794) /* registerSpanErrorInstrumentation */.addExceptionMechanism(tmp25, obj);
2026-07-20 16:05:17 +00:00
tmp14 = tmp25;
2026-07-23 10:11:24 +00:00
const obj10 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
return tmp14;
}
2026-07-23 10:11:24 +00:00
obj3 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
if ("stack" in error) {
let tmp39 = eventFromError(arg0, error);
} else {
let name = error.name;
if (!name) {
let str2 = "DOMException";
if (obj12.isDOMError(error)) {
str2 = "DOMError";
}
name = str2;
2026-07-23 10:11:24 +00:00
obj12 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
let combined = name;
if (error.message) {
const _HermesInternal2 = HermesInternal;
combined = "" + name + ": " + error.message;
}
tmp39 = eventFromString(arg0, combined, arg2, arg3);
2026-07-23 10:11:24 +00:00
const result3 = require(794) /* registerSpanErrorInstrumentation */.addExceptionTypeValue(tmp39, combined);
const obj13 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
if ("code" in error) {
const _Object = Object;
obj1 = {};
const _HermesInternal3 = HermesInternal;
2026-07-23 10:11:24 +00:00
obj1["DOMException.code"] = "" + error.code;
2026-07-20 16:05:17 +00:00
tmp39.tags = Object.assign({}, tmp39.tags, obj1);
}
return tmp39;
}
function eventFromString(arg0, combined, arg2, arg3) {
let obj = {};
if (arg3) {
if (arg2) {
const arr = parseStackFrames(arg0, arg2);
if (arr.length) {
obj = {};
obj = { value: combined };
const obj1 = { frames: arr };
obj.stacktrace = obj1;
const items = [obj];
obj.values = items;
obj.exception = obj;
}
const obj2 = { synthetic: true };
2026-07-23 10:11:24 +00:00
const result = require(794) /* registerSpanErrorInstrumentation */.addExceptionMechanism(obj, obj2);
const obj5 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
}
if (obj7.isParameterizedString(combined)) {
({ __sentry_template_string__: obj8.message, __sentry_template_values__: obj8.params } = combined);
obj.logentry = {};
return obj;
} else {
obj.message = combined;
return obj;
}
2026-07-23 10:11:24 +00:00
obj7 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
function getNonErrorObjectExceptionValue(message, isUnhandledRejection) {
let str = "exception";
2026-07-23 10:11:24 +00:00
const result = require(794) /* registerSpanErrorInstrumentation */.extractExceptionKeysForMessage(message);
2026-07-20 16:05:17 +00:00
if (isUnhandledRejection.isUnhandledRejection) {
str = "promise rejection";
}
2026-07-23 10:11:24 +00:00
const obj = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
if (obj2.isErrorEvent(message)) {
const _HermesInternal3 = HermesInternal;
let combined = "Event `ErrorEvent` captured as " + str + " with message `" + message.message + "`";
} else {
if (obj3.isEvent(message)) {
const _Object = Object;
const prototypeOf = Object.getPrototypeOf(message);
let name;
if (prototypeOf) {
name = prototypeOf.constructor.name;
}
const _HermesInternal2 = HermesInternal;
const combined1 = "Event `" + name + "` (type=" + message.type + ") captured as " + str;
while (true) {
let tmp11 = __exception;
2026-07-23 10:11:24 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
} else {
const _HermesInternal = HermesInternal;
combined = "Object captured as " + str + " with keys: " + result;
}
2026-07-23 10:11:24 +00:00
obj3 = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
}
return combined;
}
Object.defineProperty(arg5, Symbol.toStringTag, { value: "Module" });
2026-07-23 10:11:24 +00:00
const re2 = /Minified React error #\d+;/i;
2026-07-20 16:05:17 +00:00
arg5.eventFromException = function eventFromException(arg0, arg1, syntheticException) {
syntheticException = undefined;
if (null != syntheticException) {
syntheticException = syntheticException.syntheticException;
}
const tmpResult = eventFromUnknownInput(arg0, arg1, syntheticException, arg3);
2026-07-23 10:11:24 +00:00
const result = require(794) /* registerSpanErrorInstrumentation */.addExceptionMechanism(tmpResult);
2026-07-20 16:05:17 +00:00
tmpResult.level = "error";
if (tmp5) {
tmpResult.event_id = syntheticException.event_id;
}
2026-07-23 10:11:24 +00:00
const obj = require(794) /* registerSpanErrorInstrumentation */;
2026-07-20 16:05:17 +00:00
const tmp = eventFromUnknownInput;
2026-07-23 10:11:24 +00:00
tmp5 = null != syntheticException && syntheticException.event_id;
return require(794) /* registerSpanErrorInstrumentation */.resolvedSyncPromise(tmpResult);
2026-07-20 16:05:17 +00:00
};
arg5.eventFromMessage = function eventFromMessage(arg0, arg1) {
let str = "info";
if (arguments.length > 2) {
str = "info";
if (undefined !== arguments[2]) {
str = arguments[2];
}
}
let tmp;
if (arguments.length > 3) {
tmp = arguments[3];
}
let tmp2;
if (arguments.length > 4) {
tmp2 = arguments[4];
}
let syntheticException;
if (null != tmp) {
syntheticException = tmp.syntheticException;
}
const tmp3Result = eventFromString(arg0, arg1, syntheticException, tmp2);
tmp3Result.level = str;
if (tmp6) {
tmp3Result.event_id = tmp.event_id;
}
2026-07-23 10:11:24 +00:00
return require(794) /* registerSpanErrorInstrumentation */.resolvedSyncPromise(tmp3Result);
2026-07-20 16:05:17 +00:00
};
arg5.eventFromUnknownInput = eventFromUnknownInput;
arg5.exceptionFromError = exceptionFromError;
arg5.extractMessage = extractMessage;
arg5.extractType = extractType;