Initial curated Unraid-AppOps-Gateway source from 3bd6f6fee310125bfbb4d4650389a817f498724d
This commit is contained in:
commit
1dfbca08a1
528 files changed
+131054
No files matched your search
@@ -0,0 +1,16 @@
|
||||
const invalidApiResponse = /unexpected token|doctype|not valid json|json parse|syntaxerror/i;
|
||||
const htmlResponse = /<html|<!doctype|<body/i;
|
||||
|
||||
export const formatOperatorError = (error: unknown, fallback: string): string => {
|
||||
const raw = error instanceof Error ? error.message : String(error || "");
|
||||
const normalized = raw.trim();
|
||||
|
||||
if (!normalized) return fallback;
|
||||
if (invalidApiResponse.test(normalized) || htmlResponse.test(normalized)) {
|
||||
return `${fallback} De backendbron gaf geen geldige API-respons.`;
|
||||
}
|
||||
if (normalized.length > 240) {
|
||||
return `${normalized.slice(0, 237)}...`;
|
||||
}
|
||||
return normalized;
|
||||
};
|
||||
Reference in new issue
Block a user