Skip to content

Commit 3d0dfb5

Browse files
authored
refactor: improve initialization error messages (#276)
* refactor: improve initialization error messages See for example: - #273 (comment). > [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"}}}' - #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"}}} * small cleanup * line too long
1 parent 8a9fd3d commit 3d0dfb5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

apps/expert/lib/expert.ex

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ defmodule Expert do
303303
}
304304
end
305305

306-
defp initialization_error_message({:shutdown, {:failed_to_start_child, child, {reason, _}}}) do
306+
defp initialization_error_message({:shutdown, {:failed_to_start_child, child, reason}}) do
307307
case child do
308308
{Project.Node, node_name} ->
309309
node_initialization_message(node_name, reason)
@@ -319,12 +319,15 @@ defmodule Expert do
319319

320320
defp node_initialization_message(name, reason) do
321321
case reason do
322-
# NOTE:
323-
# ** (Mix.Error) httpc request failed with: ... Could not install Hex because Mix could not download metadata ...
324-
{:shutdown, {:error, :normal, message}} ->
325-
"Engine #{name} shutdown with error:\n\n#{message}"
322+
# NOTE: ~c"could not compile dependency :elixir_sense..."
323+
{:error, :normal, message} ->
324+
"Engine #{name} initialization failed with error:\n\n#{message}"
326325

327-
{:shutdown, {:node_exit, node_exit}} ->
326+
# NOTE: ** (Mix.Error) httpc request failed with: ...Could not install Hex because Mix could not download...
327+
{{:shutdown, {:error, :normal, message}}, _} ->
328+
"Engine #{name} shut down with error:\n\n#{message}"
329+
330+
{{:shutdown, {:node_exit, node_exit}}, _} ->
328331
"Engine #{name} exit with status #{node_exit.status}, last message:\n\n#{node_exit.last_message}"
329332

330333
reason ->

0 commit comments

Comments
 (0)