fix(striker-ui-api): catch exceptions in GET anvil summary list handler

main
Tsu-ba-me 1 year ago
parent 24879a3ca8
commit b15df65c07
  1. 4
      striker-ui-api/src/lib/request_handlers/anvil/getAnvilDetail.ts
  2. 14
      striker-ui-api/src/lib/request_handlers/anvil/getAnvilSummary.ts

@ -34,9 +34,7 @@ export const getAnvilDetail: RequestHandler<
hosts, hosts,
}); });
} catch (error) { } catch (error) {
stderr( stderr(`Failed to get summary of anvil node ${anvilUuid}; CAUSE: ${error}`);
`Failed to get summary of anvil node pair ${anvilUuid}; CAUSE: ${error}`,
);
return response.status(500).send(); return response.status(500).send();
} }

@ -23,10 +23,16 @@ export const getAnvilSummary: RequestHandler<unknown, AnvilSummary> = async (
const { anvil_uuid: alist } = anvils; const { anvil_uuid: alist } = anvils;
const result: AnvilSummary = { anvils: [] }; const result: AnvilSummary = { anvils: [] };
for (const auuid of Object.keys(alist)) { try {
result.anvils.push( for (const auuid of Object.keys(alist)) {
await buildAnvilSummary({ anvils, anvilUuid: auuid, hosts }), 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); response.json(result);

Loading…
Cancel
Save