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,
});
} 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();
}

@ -23,10 +23,16 @@ export const getAnvilSummary: RequestHandler<unknown, AnvilSummary> = 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);

Loading…
Cancel
Save