From b15df65c077dd958e61b9b4f2a6247136f4fa995 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Mon, 16 Oct 2023 03:22:50 -0400 Subject: [PATCH] fix(striker-ui-api): catch exceptions in GET anvil summary list handler --- .../lib/request_handlers/anvil/getAnvilDetail.ts | 4 +--- .../lib/request_handlers/anvil/getAnvilSummary.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/anvil/getAnvilDetail.ts b/striker-ui-api/src/lib/request_handlers/anvil/getAnvilDetail.ts index abcf6461..bcdf6281 100644 --- a/striker-ui-api/src/lib/request_handlers/anvil/getAnvilDetail.ts +++ b/striker-ui-api/src/lib/request_handlers/anvil/getAnvilDetail.ts @@ -34,9 +34,7 @@ export const getAnvilDetail: RequestHandler< hosts, }); } catch (error) { - stderr( - `Failed to get summary of anvil node pair ${anvilUuid}; CAUSE: ${error}`, - ); + stderr(`Failed to get summary of anvil node ${anvilUuid}; CAUSE: ${error}`); return response.status(500).send(); } diff --git a/striker-ui-api/src/lib/request_handlers/anvil/getAnvilSummary.ts b/striker-ui-api/src/lib/request_handlers/anvil/getAnvilSummary.ts index aae6e44b..2e0046d6 100644 --- a/striker-ui-api/src/lib/request_handlers/anvil/getAnvilSummary.ts +++ b/striker-ui-api/src/lib/request_handlers/anvil/getAnvilSummary.ts @@ -23,10 +23,16 @@ export const getAnvilSummary: RequestHandler = async ( const { anvil_uuid: alist } = anvils; const result: AnvilSummary = { anvils: [] }; - for (const auuid of Object.keys(alist)) { - result.anvils.push( - await buildAnvilSummary({ anvils, anvilUuid: auuid, hosts }), - ); + try { + for (const auuid of Object.keys(alist)) { + result.anvils.push( + await buildAnvilSummary({ anvils, anvilUuid: auuid, hosts }), + ); + } + } catch (error) { + stderr(`Failed to get summary of anvil nodes; CAUSE: ${error}`); + + return response.status(500).send(); } response.json(result);