From 502a6c462ff0a26926596c9a8b0f32fd2005617f Mon Sep 17 00:00:00 2001 From: jinapurapu <65002498+jinapurapu@users.noreply.github.com> Date: Wed, 22 Mar 2023 14:39:08 -0700 Subject: [PATCH] Fixed snackMessage to display if error returned creating policy (#2726) --- .../screens/Console/Policies/AddPolicyScreen.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/portal-ui/src/screens/Console/Policies/AddPolicyScreen.tsx b/portal-ui/src/screens/Console/Policies/AddPolicyScreen.tsx index 137983bbb..37b988aad 100644 --- a/portal-ui/src/screens/Console/Policies/AddPolicyScreen.tsx +++ b/portal-ui/src/screens/Console/Policies/AddPolicyScreen.tsx @@ -23,7 +23,6 @@ import InputBoxWrapper from "../Common/FormComponents/InputBoxWrapper/InputBoxWr import AddPolicyHelpBox from "./AddPolicyHelpBox"; import CodeMirrorWrapper from "../Common/FormComponents/CodeMirrorWrapper/CodeMirrorWrapper"; import { IAM_PAGES } from "../../../common/SecureComponent/permissions"; -import { ErrorResponseHandler } from "../../../common/types"; import FormLayout from "../Common/FormLayout"; import { setErrorSnackMessage } from "../../../systemSlice"; import { useNavigate } from "react-router-dom"; @@ -56,9 +55,17 @@ const AddPolicyScreen = () => { setAddLoading(false); navigate(`${IAM_PAGES.POLICIES}`); }) - .catch((err: ErrorResponseHandler) => { + .catch((err: HttpResponse) => { setAddLoading(false); - dispatch(setErrorSnackMessage(err)); + dispatch( + setErrorSnackMessage({ + errorMessage: "There was an error creating a Policy ", + detailedError: + "There was an error creating a Policy: " + + (err.error.detailedMessage || "") + + ". Please check Policy syntax.", + }) + ); }); };