fui-material 2.8.11 → 2.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/f-ui-kit.es.js
CHANGED
|
@@ -8863,6 +8863,61 @@ function fConvertDate(input, options) {
|
|
|
8863
8863
|
return "";
|
|
8864
8864
|
}
|
|
8865
8865
|
}
|
|
8866
|
+
const LONG_ERROR_FIELD_LIMIT = 2048;
|
|
8867
|
+
const SHORT_ERROR_FIELD_LIMIT = 256;
|
|
8868
|
+
const ERROR_FIELDS = [
|
|
8869
|
+
"message",
|
|
8870
|
+
"error",
|
|
8871
|
+
"code",
|
|
8872
|
+
"title",
|
|
8873
|
+
"type",
|
|
8874
|
+
"detail",
|
|
8875
|
+
"traceId",
|
|
8876
|
+
"requestId",
|
|
8877
|
+
"timestamp"
|
|
8878
|
+
];
|
|
8879
|
+
function isScalar(value) {
|
|
8880
|
+
return typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value);
|
|
8881
|
+
}
|
|
8882
|
+
function isUnsupportedResponseData(data) {
|
|
8883
|
+
return Array.isArray(data) || typeof Blob !== "undefined" && data instanceof Blob || typeof ArrayBuffer !== "undefined" && (data instanceof ArrayBuffer || ArrayBuffer.isView(data));
|
|
8884
|
+
}
|
|
8885
|
+
function normalizeRequestErrorResponse(data) {
|
|
8886
|
+
try {
|
|
8887
|
+
if (typeof data === "string") {
|
|
8888
|
+
return data.length > 0 ? { message: data.slice(0, LONG_ERROR_FIELD_LIMIT) } : void 0;
|
|
8889
|
+
}
|
|
8890
|
+
if (!data || typeof data !== "object" || isUnsupportedResponseData(data)) {
|
|
8891
|
+
return void 0;
|
|
8892
|
+
}
|
|
8893
|
+
const result = {};
|
|
8894
|
+
for (const field of ERROR_FIELDS) {
|
|
8895
|
+
const value = data[field];
|
|
8896
|
+
if (!isScalar(value)) continue;
|
|
8897
|
+
const text = String(value);
|
|
8898
|
+
result[field] = text.slice(
|
|
8899
|
+
0,
|
|
8900
|
+
field === "message" || field === "detail" ? LONG_ERROR_FIELD_LIMIT : SHORT_ERROR_FIELD_LIMIT
|
|
8901
|
+
);
|
|
8902
|
+
}
|
|
8903
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
8904
|
+
} catch {
|
|
8905
|
+
return void 0;
|
|
8906
|
+
}
|
|
8907
|
+
}
|
|
8908
|
+
function getErrorResponseData(error2) {
|
|
8909
|
+
if (!error2 || typeof error2 !== "object") return void 0;
|
|
8910
|
+
try {
|
|
8911
|
+
const response = error2.response;
|
|
8912
|
+
if (!response || typeof response !== "object") return void 0;
|
|
8913
|
+
return response.data;
|
|
8914
|
+
} catch {
|
|
8915
|
+
return void 0;
|
|
8916
|
+
}
|
|
8917
|
+
}
|
|
8918
|
+
function getRequestErrorResponse(error2) {
|
|
8919
|
+
return normalizeRequestErrorResponse(getErrorResponseData(error2));
|
|
8920
|
+
}
|
|
8866
8921
|
const getRequestNow = () => {
|
|
8867
8922
|
if (typeof performance !== "undefined" && typeof performance.now === "function") {
|
|
8868
8923
|
return performance.now();
|
|
@@ -8943,13 +8998,15 @@ async function observeRequest(observer, requestFn, method, url) {
|
|
|
8943
8998
|
} catch (error2) {
|
|
8944
8999
|
const durationMs = calcDurationMs(startTime);
|
|
8945
9000
|
const { outcome, errorCategory, status } = classifyRequestError(error2);
|
|
9001
|
+
const errorResponse = outcome === "failure" ? getRequestErrorResponse(error2) : void 0;
|
|
8946
9002
|
notifyRequestObserver(observer, {
|
|
8947
9003
|
method: normalizedMethod,
|
|
8948
9004
|
url,
|
|
8949
9005
|
status,
|
|
8950
9006
|
durationMs,
|
|
8951
9007
|
outcome,
|
|
8952
|
-
errorCategory
|
|
9008
|
+
errorCategory,
|
|
9009
|
+
...errorResponse ? { errorResponse } : {}
|
|
8953
9010
|
});
|
|
8954
9011
|
throw error2;
|
|
8955
9012
|
}
|
|
@@ -9042,13 +9099,15 @@ const useFApi = ({
|
|
|
9042
9099
|
} catch (error22) {
|
|
9043
9100
|
if (effectiveObserver) {
|
|
9044
9101
|
const { outcome, errorCategory, status } = classifyRequestError(error22);
|
|
9102
|
+
const errorResponse = outcome === "failure" ? getRequestErrorResponse(error22) : void 0;
|
|
9045
9103
|
notifyRequestObserver(effectiveObserver, {
|
|
9046
9104
|
method,
|
|
9047
9105
|
url,
|
|
9048
9106
|
status,
|
|
9049
9107
|
durationMs: calcDurationMs(startTime),
|
|
9050
9108
|
outcome,
|
|
9051
|
-
errorCategory
|
|
9109
|
+
errorCategory,
|
|
9110
|
+
...errorResponse ? { errorResponse } : {}
|
|
9052
9111
|
});
|
|
9053
9112
|
}
|
|
9054
9113
|
const err = error22;
|