Compare commits

...

2 Commits

Author SHA1 Message Date
shamoon
4031178831 Enhancement: treat 'error' as custom api field when mapped (#5999) 2025-11-21 10:36:31 -08:00
shamoon
b65c8399d8 Handle raw number errors, I guess 2025-11-21 10:05:01 -08:00
2 changed files with 7 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ export default function Error({ error }) {
if (typeof error === "string") {
error = { message: error }; // eslint-disable-line no-param-reassign
} else if (typeof error === "number") {
error = { message: `Error ${error}` }; // eslint-disable-line no-param-reassign
}
if (error?.data?.error) {

View File

@@ -166,7 +166,11 @@ export default function Component({ service }) {
refreshInterval: Math.max(1000, refreshInterval),
});
if (customError) {
// if mappings includes an error field and the data contains an error field then show data even if there is an error
const mappingsIncludesError = Array.isArray(mappings) && mappings.find((mapping) => mapping.field === "error");
const errorIsData = customData && typeof customData === "object" && "error" in customData;
if (customError && !(mappingsIncludesError && errorIsData)) {
return <Container service={service} error={customError} />;
}