Skip to content

Commit

Permalink
don't crash language server if suggest_contracts fails
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Nov 6, 2023
1 parent 7d4c147 commit b519601
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion apps/language_server/lib/language_server/dialyzer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ defmodule ElixirLS.LanguageServer.Dialyzer do
def suggest_contracts(_server, []), do: []

def suggest_contracts(server, files) do
GenServer.call(server, {:suggest_contracts, files}, :infinity)
try do
GenServer.call(server, {:suggest_contracts, files}, :infinity)
catch
kind, payload ->
{payload, stacktrace} = Exception.blame(kind, payload, __STACKTRACE__)
error_msg = Exception.format(kind, payload, stacktrace)

Logger.error("Unable to suggest contracts: #{error_msg}")
[]
end
end

# Server callbacks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule ElixirLS.LanguageServer.Dialyzer.Manifest do

JsonRpc.show_message(
:error,
"Unable to build dialyzer PLT. Most likely there are problems with your OTP and elixir installation."
"Unable to build dialyzer PLT. Please make sure that #{elixir_plt_path()} is writable and your OTP install is complete. Visit https://github.com/elixir-lsp/elixir-ls/issues/540 for help"
)

Logger.error("Dialyzer PLT build process exited with reason: #{error_msg}")
Expand Down

0 comments on commit b519601

Please sign in to comment.