fix(striker-ui): correct response status when no records in fetch anvil cpu

main
Tsu-ba-me 1 year ago
parent ac28ea88df
commit bf19d03ee5
  1. 9
      striker-ui-api/src/lib/request_handlers/anvil/getAnvilCpu.ts

@ -1,4 +1,3 @@
import assert from 'assert';
import { RequestHandler } from 'express';
import { query } from '../../accessModule';
@ -49,14 +48,14 @@ export const getAnvilCpu: RequestHandler<AnvilDetailParamsDictionary> = async (
c.scan_hardware_cpu_threads
ORDER BY b.host_name;`,
);
assert.ok(rCpus.length, 'No entry found');
} catch (error) {
stderr(`Failed to get anvil ${anvilUuid} cpu info; CAUSE: ${error}`);
return response.status(500).send();
}
if (!rCpus.length) return response.status(404).send();
let rAllocatedRow: [cpuAllocated: string][];
try {
@ -74,14 +73,14 @@ export const getAnvilCpu: RequestHandler<AnvilDetailParamsDictionary> = async (
ON a.server_uuid = b.server_definition_server_uuid
WHERE a.server_anvil_uuid = '${anvilUuid}';`,
);
assert.ok(rAllocatedRow.length, 'No entry found');
} catch (error) {
stderr(`Failed to get anvil ${anvilUuid} server cpu info; CAUSE: ${error}`);
return response.status(500).send();
}
if (!rAllocatedRow.length) return response.status(404).send();
const {
0: { 5: rMinCores, 6: rMinThreads },
} = rCpus;

Loading…
Cancel
Save