From a53fda39cee303b33b6c42080e830051964fe904 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 1 Jul 2022 09:09:40 -0400 Subject: [PATCH] UI: Throw exception from resetAll() --- .../ui-components/IslandResetModal.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx b/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx index a6eef2070..8936cc077 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx @@ -75,16 +75,11 @@ const IslandResetModal = (props: Props) => { onClick={() => { setResetAll(Loading); try { - resetAll().then(res => { - if (res.status === 200) { - setResetAll(Done); - props.onClose(); - } else { - throw 'Error resetting the simulation' - } - }) + resetAll(); + setResetAll(Done); + props.onClose(); } catch (err) { - // TODO: Display error message + // TODO: Display error message to user console.error(err) } }}> @@ -107,7 +102,7 @@ const IslandResetModal = (props: Props) => { }) } function resetAll() { - return auth.authFetch('/api/reset-agent-configuration', {method: 'POST'}) + auth.authFetch('/api/reset-agent-configuration', {method: 'POST'}) .then(res => { if (res.status === 200) { return auth.authFetch('/api/clear-simulation-data', {method: 'POST'}) @@ -116,6 +111,11 @@ const IslandResetModal = (props: Props) => { if (res.status === 200) { return auth.authFetch('/api/island-mode', {method: 'POST', body: '{"mode": "unset"}'}) }) + .then(res => { + if (res.status !== 200) { + throw 'Error resetting the simulation' + } + }) } function showModalButtons() {