From b7420ea04a390ce208fe56c2c02455590bf22726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20L=C3=A9vesque?= Date: Sun, 1 Nov 2020 12:39:55 -0500 Subject: [PATCH] Handle errors in server request --- .../lib/language_server/server.ex | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/language_server/lib/language_server/server.ex b/apps/language_server/lib/language_server/server.ex index 26faac8e8..9cabd4f57 100644 --- a/apps/language_server/lib/language_server/server.ex +++ b/apps/language_server/lib/language_server/server.ex @@ -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} @@ -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