Skip to content

Commit 7e0f737

Browse files
committed
don't send telemetry on expected errors
1 parent b81b12a commit 7e0f737

File tree

16 files changed

+69
-64
lines changed

16 files changed

+69
-64
lines changed

apps/language_server/lib/language_server/dialyzer/analyzer.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule ElixirLS.LanguageServer.Dialyzer.Analyzer do
22
require Record
33
require Logger
4+
alias ElixirLS.LanguageServer.JsonRpc
45

56
# warn_race_condition is unsupported because it greatly increases analysis time
67
# OTP 25 dropped support for warn_race_condition

apps/language_server/lib/language_server/providers/document_symbols.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ defmodule ElixirLS.LanguageServer.Providers.DocumentSymbols do
3232
{:ok, build_symbols(symbols, uri, text, hierarchical)}
3333

3434
{:error, :compilation_error} ->
35-
{:error, :server_error, "[DocumentSymbols] Compilation error while parsing source file"}
35+
{:error, :server_error, "Cannot parse source file", false}
3636
end
3737
end
3838

apps/language_server/lib/language_server/providers/execute_command.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand do
2323
handler.execute(args, state)
2424
else
2525
_ ->
26-
{:error, :invalid_request, nil}
26+
{:error, :invalid_request, nil, true}
2727
end
2828
end
2929

apps/language_server/lib/language_server/providers/execute_command/apply_spec.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ApplySpec do
9090

9191
other ->
9292
{:error, :server_error,
93-
"cannot insert spec, workspace/applyEdit returned #{inspect(other)}"}
93+
"cannot insert spec, workspace/applyEdit returned #{inspect(other)}", true}
9494
end
9595
end
9696
end

apps/language_server/lib/language_server/providers/execute_command/get_ex_unit_tests_in_file.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.GetExUnitTestsInFile
77
path = SourceFile.Path.from_uri(uri)
88

99
case ExUnitTestTracer.get_tests(path) do
10-
{:ok, tests} -> {:ok, tests}
11-
{:error, reason} -> {:error, :server_error, inspect(reason)}
10+
{:ok, tests} ->
11+
{:ok, tests}
12+
13+
{:error, reason} ->
14+
{:error, :server_error, "Cannot get tests in file: #{inspect(reason)}", true}
1215
end
1316
end
1417
end

apps/language_server/lib/language_server/providers/execute_command/manipulate_pipes.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipes do
5252
{:ok, nil}
5353
else
5454
{:error, :pipe_not_found} ->
55-
{:error, :parse_error, "Pipe operator not found at cursor"}
55+
{:error, :parse_error, "Pipe operator not found at cursor", false}
5656

5757
{:error, :function_call_not_found} ->
58-
{:error, :parse_error, "Function call not found at cursor"}
58+
{:error, :parse_error, "Function call not found at cursor", false}
5959

6060
{:error, :invalid_code} ->
61-
{:error, :parse_error, "Malformed code"}
61+
{:error, :parse_error, "Malformed code", false}
6262

6363
error ->
6464
{:error, :server_error,
65-
"Cannot execute pipe conversion, workspace/applyEdit returned #{inspect(error)}"}
65+
"Cannot execute pipe conversion, workspace/applyEdit returned #{inspect(error)}", true}
6666
end
6767
end
6868

apps/language_server/lib/language_server/providers/execute_command/mix_clean.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.MixClean do
55
def execute([clean_deps?], _state) do
66
case ElixirLS.LanguageServer.Build.clean(clean_deps?) do
77
:ok -> {:ok, %{}}
8-
{:error, reason} -> {:error, :server_error, inspect(reason)}
8+
{:error, reason} -> {:error, :server_error, "Mix clean failed: #{inspect(reason)}", true}
99
end
1010
end
1111
end

apps/language_server/lib/language_server/providers/folding_range.ex

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,11 @@ defmodule ElixirLS.LanguageServer.Providers.FoldingRange do
8484
]}
8585
8686
"""
87-
@spec provide(%{text: String.t()}) :: {:ok, [t()]} | {:error, String.t()}
87+
@spec provide(%{text: String.t()}) :: {:ok, [t()]}
8888
def provide(%{text: text}) do
8989
do_provide(text)
9090
end
9191

92-
def provide(not_a_source_file) do
93-
{:error, "Expected a source file, found: #{inspect(not_a_source_file)}"}
94-
end
95-
9692
defp do_provide(text) do
9793
input = convert_text_to_input(text)
9894

apps/language_server/lib/language_server/providers/folding_range/token.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ defmodule ElixirLS.LanguageServer.Providers.FoldingRange.Token do
66
"""
77

88
alias ElixirSense.Core.Normalized.Tokenizer
9+
alias ElixirLS.LanguageServer.JsonRpc
910
require Logger
1011

1112
@type t :: {atom(), {non_neg_integer(), non_neg_integer(), any()}, any()}

apps/language_server/lib/language_server/providers/formatting.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ defmodule ElixirLS.LanguageServer.Providers.Formatting do
1515
end
1616

1717
:error ->
18-
{:error, :internal_error, "Unable to fetch formatter options"}
18+
{:error, :internal_error, "Unable to fetch formatter options", true}
1919
end
2020
else
2121
msg =
2222
"Cannot format file from current directory " <>
2323
"(Currently in #{Path.relative_to(File.cwd!(), project_dir)})"
2424

25-
{:error, :internal_error, msg}
25+
{:error, :internal_error, msg, true}
2626
end
2727
end
2828

@@ -42,7 +42,7 @@ defmodule ElixirLS.LanguageServer.Providers.Formatting do
4242
{:ok, response}
4343
rescue
4444
_e in [TokenMissingError, SyntaxError] ->
45-
{:error, :internal_error, "Unable to format due to syntax error"}
45+
{:error, :internal_error, "Unable to format due to syntax error", false}
4646
end
4747

4848
defp get_formatted(text, formatter, _) when is_function(formatter) do

0 commit comments

Comments
 (0)