From ab6e8e2eb789d078ec5255780ea4de965e74535f Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Mon, 22 Dec 2025 16:00:35 -0300 Subject: [PATCH 1/3] refactor: improve initialization error messages See for example: - https://github.com/elixir-lang/expert/issues/273#issue-3750378857. > [ERROR][2025-12-20 12:11:21] ...lsp/handlers.lua:562 '[Project file:///path/to/project] Failed to initialize: {:shutdown, {:failed_to_start_child, {XPExpert.Project.Node, "project"}, {:error, :normal, ~c"could not compile dependency :elixir_sense, \\"mix compile\\" failed. Errors may have been logged above. You can recompile this dependency with \\"mix deps.compile elixir_sense --force\\", update it with \\"mix deps.update elixir_sense\\" or clean it with \\"mix deps.clean elixir_sense\\"\\n"}}}' - https://github.com/elixir-lang/expert/issues/266 > [Project file:///d%3A/proj/hello] Failed to initialize: {:shutdown, {:failed_to_start_child, {XPExpert.Project.Node, "hello"}, {:error, :normal, ~c"done\r\n"}}} --- apps/expert/lib/expert.ex | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/expert/lib/expert.ex b/apps/expert/lib/expert.ex index 1d5905f4..539eedc2 100644 --- a/apps/expert/lib/expert.ex +++ b/apps/expert/lib/expert.ex @@ -303,7 +303,7 @@ defmodule Expert do } end - defp initialization_error_message({:shutdown, {:failed_to_start_child, child, {reason, _}}}) do + defp initialization_error_message({:shutdown, {:failed_to_start_child, child, reason}}) do case child do {Project.Node, node_name} -> node_initialization_message(node_name, reason) @@ -319,12 +319,16 @@ defmodule Expert do defp node_initialization_message(name, reason) do case reason do + # NOTE: {:error, :normal, ~c"could not compile dependency :elixir_sense..."} + {:error, :normal, message} -> + "Engine #{name} initialization failed with error:\n\n#{message}" + # NOTE: # ** (Mix.Error) httpc request failed with: ... Could not install Hex because Mix could not download metadata ... - {:shutdown, {:error, :normal, message}} -> - "Engine #{name} shutdown with error:\n\n#{message}" + {{:shutdown, {:error, :normal, message}}, _} -> + "Engine #{name} shut down with error:\n\n#{message}" - {:shutdown, {:node_exit, node_exit}} -> + {{:shutdown, {:node_exit, node_exit}}, _} -> "Engine #{name} exit with status #{node_exit.status}, last message:\n\n#{node_exit.last_message}" reason -> From 4e8705652eee68fd5bf03c47d01fd8a1dcb93cf3 Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Mon, 22 Dec 2025 16:03:03 -0300 Subject: [PATCH 2/3] small cleanup --- apps/expert/lib/expert.ex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/expert/lib/expert.ex b/apps/expert/lib/expert.ex index 539eedc2..5552f7d9 100644 --- a/apps/expert/lib/expert.ex +++ b/apps/expert/lib/expert.ex @@ -319,12 +319,11 @@ defmodule Expert do defp node_initialization_message(name, reason) do case reason do - # NOTE: {:error, :normal, ~c"could not compile dependency :elixir_sense..."} + # NOTE: ~c"could not compile dependency :elixir_sense..." {:error, :normal, message} -> "Engine #{name} initialization failed with error:\n\n#{message}" - # NOTE: - # ** (Mix.Error) httpc request failed with: ... Could not install Hex because Mix could not download metadata ... + # NOTE: ** (Mix.Error) httpc request failed with: ... Could not install Hex because Mix could not download metadata ... {{:shutdown, {:error, :normal, message}}, _} -> "Engine #{name} shut down with error:\n\n#{message}" From d1acd4922e2f4b810bc0523cc76100024cfc911a Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Mon, 22 Dec 2025 16:13:10 -0300 Subject: [PATCH 3/3] line too long --- apps/expert/lib/expert.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/expert/lib/expert.ex b/apps/expert/lib/expert.ex index 5552f7d9..4988e47b 100644 --- a/apps/expert/lib/expert.ex +++ b/apps/expert/lib/expert.ex @@ -323,7 +323,7 @@ defmodule Expert do {:error, :normal, message} -> "Engine #{name} initialization failed with error:\n\n#{message}" - # NOTE: ** (Mix.Error) httpc request failed with: ... Could not install Hex because Mix could not download metadata ... + # NOTE: ** (Mix.Error) httpc request failed with: ...Could not install Hex because Mix could not download... {{:shutdown, {:error, :normal, message}}, _} -> "Engine #{name} shut down with error:\n\n#{message}"