♻️ CLI move error handling code from handler to runWithPlatform

This commit is contained in:
Eric Doughty-Papassideris
2024-03-28 01:57:17 +01:00
committed by ericlinagora
parent aac4caafaa
commit 9a7518eba1
2 changed files with 15 additions and 15 deletions
@@ -29,8 +29,13 @@ export default async function runWithPlatform(
const platform = await tdrive.run(config.get("services"));
await gr.doInit(platform);
spinner.succeed("Platform: started");
const exitCode = await handler({ spinner, config, platform });
if (typeof exitCode === "number") process.exitCode = exitCode;
try {
const exitCode = await handler({ spinner, config, platform });
if (typeof exitCode === "number") process.exitCode = exitCode;
} catch (err) {
spinner.fail(err.stack || err);
process.exitCode = 1;
}
spinner.start("Platform: shutting down...");
await platform.stop();
spinner.succeed("Platform: shutdown");