Skip to content

Commit

Permalink
raise server error on launch failure
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Oct 22, 2023
1 parent f2fcb18 commit 5d9ab5e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
13 changes: 8 additions & 5 deletions apps/elixir_ls_debugger/lib/debugger/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,19 @@ defmodule ElixirLS.Debugger.Server do

{:DOWN, ^ref, :process, _pid, reason} ->
if reason != :normal do
Output.debugger_important("Launch request failed")
message = "Launch request failed with reason\n" <> Exception.format_exit(reason)

Output.debugger_console(
"Launch request failed with reason\n" <> Exception.format_exit(reason)
)
Output.debugger_console(message)

exit_code = 1
Output.send_event("exited", %{"exitCode" => exit_code})
Output.send_event("terminated", %{"restart" => false})
config

raise ServerError,
message: "launchError",
format: message,
variables: %{},
show_user: true
else
raise "exit reason #{inspect(reason)} was not expected"
end
Expand Down
17 changes: 15 additions & 2 deletions apps/elixir_ls_debugger/test/debugger_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ defmodule ElixirLS.Debugger.ServerTest do
end

@tag :fixture
test "launch mix task that fails to initialze", %{server: server} do
test "launch mix task that fails to initialize", %{server: server} do
in_fixture(__DIR__, "mix_project", fn ->
Server.receive_packet(
server,
Expand All @@ -474,7 +474,20 @@ defmodule ElixirLS.Debugger.ServerTest do
})
)

assert_receive(response(_, 2, "launch", %{}), 5000)
assert_receive(
error_response(
_,
2,
"launch",
"launchError",
"Launch request failed with reason" <> _,
%{},
_,
_
),
5000
)

refute_receive(event(_, "initialized", %{}))

assert_receive event(_, "output", %{
Expand Down

0 comments on commit 5d9ab5e

Please sign in to comment.