decord/source/modules/auth/getAuthenticationErrorsFromAPIError.tsx
2026-07-25 08:10:48 +00:00

45 lines
1.4 KiB
TypeScript

// Module ID: 9128
// Function ID: 71740
// Name: getAuthenticationErrorsFromAPIError
// Dependencies: [2]
// Exports: getAuthenticationErrorsFromAPIError, getAuthenticationErrorsFromV6OrEarlierAPIError
// Module 9128 (getAuthenticationErrorsFromAPIError)
const result = require("set").fileFinishedImporting("modules/auth/getAuthenticationErrorsFromAPIError.tsx");
export const getAuthenticationErrorsFromAPIError = function getAuthenticationErrorsFromAPIError(error) {
let length;
const obj = { error_code: error.code };
if (null != error.errors) {
const _Object = Object;
const keys = Object.keys(error.errors);
let num = 0;
if (0 < keys.length) {
do {
let tmp2 = keys[num];
let items = [error.getFirstFieldErrorMessage(tmp2)];
obj[tmp2] = items;
num = num + 1;
length = keys.length;
} while (num < length);
}
return obj;
} else {
obj.message = error.message;
if (null != error.retryAfter) {
obj.retry_after = error.retryAfter;
}
return obj;
}
};
export const getAuthenticationErrorsFromV6OrEarlierAPIError = function getAuthenticationErrorsFromV6OrEarlierAPIError(error) {
if (Object.keys(error.fields).length > 0) {
return error.fields;
} else {
const obj = { message: error.message };
if (null != error.retryAfter) {
obj.retry_after = error.retryAfter;
}
return obj;
}
};