From 90806493edc94da750be5730f1daf8652c4c2e10 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 10 Oct 2025 12:18:47 +0900 Subject: [PATCH] Refactor code editor launch logic Extracted the code editor launch logic into a new LaunchEditor() method to reduce duplication. Both the button and menu item now use this method, and error handling for resource server startup is centralized. --- .../WelsonJS.Launcher/MainForm.cs | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs index 05b4786..f55da4b 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs @@ -243,6 +243,24 @@ namespace WelsonJS.Launcher } } + private void LaunchEditor() + { + if (RunResourceServer()) + { + Program.OpenWebBrowser(Program._resourceServer.GetPrefix()); + } + else + { + _logger.Error("Failed to start the resource server."); + MessageBox.Show( + "Failed to start the resource server. Please check your configuration or try again.", + "Resource Server Error", + MessageBoxButtons.OK, + MessageBoxIcon.Error + ); + } + } + private void cbUseSpecificScript_CheckedChanged(object sender, EventArgs e) { txtUseSpecificScript.Enabled = cbUseSpecificScript.Checked; @@ -291,12 +309,14 @@ namespace WelsonJS.Launcher (new GlobalSettingsForm()).Show(); } + private void btnStartTheEditor_Click(object sender, EventArgs e) + { + LaunchEditor(); + } + private void startCodeEditorToolStripMenuItem_Click(object sender, EventArgs e) { - if (RunResourceServer()) - { - Program.OpenWebBrowser(Program._resourceServer.GetPrefix()); - } + LaunchEditor(); } private void openCodeEditorToolStripMenuItem_Click(object sender, EventArgs e) @@ -315,14 +335,6 @@ namespace WelsonJS.Launcher Program.OpenWebBrowser(Program.GetAppConfig("CopilotUrl")); } - private void btnStartTheEditor_Click(object sender, EventArgs e) - { - if (RunResourceServer()) - { - Program.OpenWebBrowser(Program._resourceServer.GetPrefix()); - } - } - private void btnJoinTheCommunity_Click(object sender, EventArgs e) { Program.OpenWebBrowser(Program.GetAppConfig("RepositoryUrl"));