decord/source/modules/errors/ErrorHandlingUtils.tsx

78 lines
2.3 KiB
TypeScript
Raw Normal View History

// Module ID: 7391
// Function ID: 7392
// Name: ErrorHandlingUtils
// Dependencies: [1074, 1232, 2]
2026-07-20 16:05:17 +00:00
// Exports: captureOrIgnoreApiError
// Module 7391 (ErrorHandlingUtils)
import Constants from "Constants" /* 1074 */;
import SentryUtilsDefault from "SentryUtils" /* 1232 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
const items = [, , ];
({ UNAUTHORIZED: arr[0], EMAIL_VERIFICATION_REQUIRED: arr[1], USER_BANNED: arr[2] } = Constants.AbortCodes);
const set = new Set([500, 502, 503, 504]);
2026-07-23 10:11:24 +00:00
const set1 = new Set([401, 403, 405, 409, 429]);
const result = size.fileFinishedImporting("modules/errors/ErrorHandlingUtils.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const captureOrIgnoreApiError = function captureOrIgnoreApiError(aPIError) {
let tmp = null == aPIError;
2026-07-20 16:05:17 +00:00
if (!tmp) {
let flag = false;
2026-07-29 08:29:29 +00:00
if (null != aPIError) {
let cause;
if (aPIError != null) {
cause = aPIError.cause;
2026-07-20 16:05:17 +00:00
}
let crossDomain;
2026-07-29 08:29:29 +00:00
if (cause != null) {
2026-07-20 16:05:17 +00:00
crossDomain = cause.crossDomain;
}
let tmp4 = true === crossDomain;
if (!tmp4) {
2026-08-04 21:03:28 +00:00
let tmp5 = !("status" in aPIError) || typeof aPIError.status !== "number";
2026-07-29 08:29:29 +00:00
if (!tmp5) {
let tmp6 = 0 !== aPIError.status;
if (tmp6) {
tmp6 = !set.has(aPIError.status);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp6) {
tmp6 = !set1.has(aPIError.status);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp5 = tmp6;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp9 = !tmp5;
if (tmp5) {
2026-08-04 21:03:28 +00:00
let tmp10 = !("code" in aPIError) || typeof aPIError.code !== "number";
2026-07-29 08:29:29 +00:00
if (!tmp10) {
tmp10 = !items.includes(aPIError.code);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp12 = !tmp10;
if (tmp10) {
2026-08-04 21:03:28 +00:00
let hasItem = "body" in aPIError && null != aPIError.body && typeof aPIError.body === "object" && "code" in aPIError.body;
2026-07-20 16:05:17 +00:00
if (hasItem) {
2026-07-29 08:29:29 +00:00
const body = aPIError.body;
2026-07-20 16:05:17 +00:00
let code;
2026-07-29 08:29:29 +00:00
if (body != null) {
2026-07-20 16:05:17 +00:00
code = body.code;
}
2026-08-04 21:03:28 +00:00
hasItem = typeof code === "number";
2026-07-20 16:05:17 +00:00
}
if (hasItem) {
2026-07-29 08:29:29 +00:00
hasItem = items.includes(aPIError.body.code);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp12 = hasItem;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp9 = tmp12;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp4 = tmp9;
2026-07-20 16:05:17 +00:00
}
flag = tmp4;
}
tmp = flag;
}
if (!tmp) {
SentryUtilsDefault.captureException(aPIError);
2026-07-20 16:05:17 +00:00
}
};