Skip to content

Commit

Permalink
[TM-1552] fix display of error messages (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
egrojMonroy authored Dec 9, 2024
1 parent 7a8b51b commit f473b77
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/admin/components/ResourceTabs/PolygonReviewTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,23 +347,31 @@ const PolygonReviewTab: FC<IProps> = props => {
setSubmitPolygonLoaded(false);
hideLoader();
} catch (error) {
if (error && typeof error === "object" && "message" in error) {
let errorMessage = error.message;
if (typeof errorMessage === "string") {
const parsedMessage = JSON.parse(errorMessage);
if (parsedMessage && typeof parsedMessage === "object" && "message" in parsedMessage) {
errorMessage = parsedMessage.message;
let errorMessage;

if (error && typeof error === "object" && "error" in error) {
const nestedError = error.error;
if (typeof nestedError === "string") {
try {
const parsedNestedError = JSON.parse(nestedError);
if (parsedNestedError && typeof parsedNestedError === "object" && "message" in parsedNestedError) {
errorMessage = parsedNestedError.message;
} else {
errorMessage = nestedError;
}
} catch (parseError) {
errorMessage = nestedError;
}
} else {
errorMessage = nestedError;
}
if (errorMessage && typeof errorMessage === "object" && "message" in errorMessage) {
errorMessage = errorMessage.message;
}
openNotification("error", t("Error uploading file"), errorMessage);
hideLoader();
} else if (error && typeof error === "object" && "message" in error) {
errorMessage = error.message;
} else {
openNotification("error", t("Error uploading file"), t("An unknown error occurred"));
hideLoader();
errorMessage = t("An unknown error occurred");
}
openNotification("error", t("Error uploading file"), errorMessage || t("An unknown error occurred"));
hideLoader();
}
};

Expand Down

0 comments on commit f473b77

Please sign in to comment.