From efed2c34a9266a58e8b729d60b0ae55278a7f779 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 20 Dec 2021 10:45:02 -0600 Subject: gracefully handle errors updating config --- src/web/src/components/System/Options/Edit.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/System/Options/Edit.js b/src/web/src/components/System/Options/Edit.js index a68b6fcf..54c0131f 100644 --- a/src/web/src/components/System/Options/Edit.js +++ b/src/web/src/components/System/Options/Edit.js @@ -10,6 +10,7 @@ const Edit = ({ cancelAction }) => { const [{ loading, error }, setLoading] = useState({ loading: true, error: false }); const [{ location, yaml, isDirty }, setYaml] = useState({ location: undefined, yaml: undefined, isDirty: false }); const [yamlError, setYamlError] = useState(); + const [updateError, setUpdateError] = useState(); useEffect(() => { get(); @@ -42,8 +43,13 @@ const Edit = ({ cancelAction }) => { await validate(yaml); if (!yamlError) { - await updateYaml({ yaml }); - cancelAction(); + try { + await updateYaml({ yaml }); + cancelAction(); + } + catch (error) { + setUpdateError(error.response.data); + } } } @@ -61,14 +67,14 @@ const Edit = ({ cancelAction }) => { Editing {location}
update(value)} />
- {yamlError && {yamlError}} + {(yamlError || updateError) && {(yamlError ?? '') + (updateError ?? '')}}
-- cgit v1.2.3