From 9a683584328b2533aaeab413999c3b0a05f341f1 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Mon, 27 Jul 2026 02:17:34 +0100 Subject: [PATCH] Enhance server initialization error handling and logging - Introduce a check for the Farm Control Server status during initialization, providing clearer feedback when the server is not running. - Improve error handling by logging specific failure messages instead of throwing errors, enhancing user experience during startup. --- src/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 8bbdfee..b827987 100644 --- a/src/index.js +++ b/src/index.js @@ -34,16 +34,24 @@ export async function init(options = {}) { const headless = options.headless ?? isHeadless; cli.blank(); startWaiting("Checking if Farm Control Server is running...", logger); + const isCommandLines = otpCode != undefined || isInfo == true; let runningServer; try { runningServer = await checkRunning(); await stopWaiting(); + if (runningServer == false && isCommandLines == true) { + cli.failure("Farm Control Server is not running."); + cli.blank(); + return false; + } } catch (err) { await stopWaiting(); - throw err; + cli.failure("Failed to check if Farm Control Server is running:", err); + cli.blank(); + return false; } - if (otpCode != undefined || isInfo == true) { + if (isCommandLines == true) { cli.success("Farm Control Server is running."); }