Skip to content

Commit

Permalink
attempt to show error message before crashing
Browse files Browse the repository at this point in the history
Fixes #741
  • Loading branch information
lukaszsamson committed Oct 11, 2022
1 parent 2c215a2 commit 2c78f5a
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions apps/language_server/lib/language_server/cli.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,39 @@ defmodule ElixirLS.LanguageServer.CLI do
WireProtocol.stream_packets(&JsonRpc.receive_packet/1)
end

defp start_language_server do
defp incomplete_installation_message(hash \\ "") do
guide =
"https://github.com/elixir-lsp/elixir-ls/blob/master/guides/incomplete-installation.md"

"Unable to start ElixirLS due to an incomplete erlang installation. " <>
"See #{guide}#{hash} for guidance."
end

defp start_language_server do
case Application.ensure_all_started(:language_server, :temporary) do
{:ok, _} ->
:ok

{:error, {:edoc, {'no such file or directory', 'edoc.app'}}} ->
raise "Unable to start ElixirLS due to an incomplete erlang installation. " <>
"See #{guide}#edoc-missing for guidance."
message = incomplete_installation_message("#edoc-missing")

JsonRpc.show_message(:error, message)
Process.sleep(5000)
raise message

{:error, {:dialyzer, {'no such file or directory', 'dialyzer.app'}}} ->
raise "Unable to start ElixirLS due to an incomplete erlang installation. " <>
"See #{guide}#dialyzer-missing for guidance."
message = incomplete_installation_message("#dialyzer-missing")

JsonRpc.show_message(:error, message)
Process.sleep(5000)
raise message

{:error, _} ->
raise "Unable to start ElixirLS due to an incomplete erlang installation. " <>
"See #{guide} for guidance."
message = incomplete_installation_message()

JsonRpc.show_message(:error, message)
Process.sleep(5000)
raise message
end
end
end

0 comments on commit 2c78f5a

Please sign in to comment.