Skip to content

Commit

Permalink
Handle errors in server request
Browse files Browse the repository at this point in the history
  • Loading branch information
Étienne Lévesque committed Nov 1, 2020
1 parent bd49269 commit b7420ea
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions apps/language_server/lib/language_server/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,10 @@ defmodule ElixirLS.LanguageServer.Server do

defp handle_request(code_lens_req(_id, uri), state) do
fun = fn ->
{:ok, spec_code_lens} =
if dialyzer_enabled?(state) and state.settings["suggestSpecs"] != false do
CodeLens.spec_code_lens(state.server_instance_id, uri, state.source_files[uri].text)
else
[]
end

{:ok, test_code_lens} = CodeLens.test_code_lens(uri, state.source_files[uri].text)

{:ok, spec_code_lens ++ test_code_lens}
with {:ok, spec_code_lens} <- get_spec_code_lens(state, uri),
{:ok, test_code_lens} <- CodeLens.test_code_lens(uri, state.source_files[uri].text) do
{:ok, spec_code_lens ++ test_code_lens}
end
end

{:async, fun, state}
Expand Down Expand Up @@ -602,6 +596,14 @@ defmodule ElixirLS.LanguageServer.Server do
}
end

defp get_spec_code_lens(state, uri) do
if dialyzer_enabled?(state) and state.settings["suggestSpecs"] != false do
CodeLens.spec_code_lens(state.server_instance_id, uri, state.source_files[uri].text)
else
{:ok, []}
end
end

# Build

defp trigger_build(state) do
Expand Down

0 comments on commit b7420ea

Please sign in to comment.