Skip to content

Commit c1eb5a1

Browse files
committed
don't send telemetry for common errors
1 parent a47a1ec commit c1eb5a1

File tree

1 file changed

+38
-30
lines changed
  • apps/elixir_ls_debugger/lib/debugger

1 file changed

+38
-30
lines changed

apps/elixir_ls_debugger/lib/debugger/server.ex

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,8 @@ defmodule ElixirLS.Debugger.Server do
427427
request(_, command) ->
428428
raise ServerError,
429429
message: "invalidRequest",
430-
format: "Debugger request {command} was not expected",
431-
variables: %{
432-
"command" => command
433-
}
430+
format: "Debugger request #{command} was not expected",
431+
variables: %{}
434432
end
435433
else
436434
state =
@@ -658,10 +656,8 @@ defmodule ElixirLS.Debugger.Server do
658656
defp handle_request(initialize_req(_, _client_info), _state = %__MODULE__{}) do
659657
raise ServerError,
660658
message: "invalidRequest",
661-
format: "Debugger request {command} was not expected",
662-
variables: %{
663-
"command" => "initialize"
664-
}
659+
format: "Debugger request #{command} was not expected",
660+
variables: %{}
665661
end
666662

667663
defp handle_request(cancel_req(_, args), %__MODULE__{requests: requests} = state) do
@@ -697,7 +693,8 @@ defmodule ElixirLS.Debugger.Server do
697693
format: "Request or progress {reguestOrProgressId} cannot be cancelled",
698694
variables: %{
699695
"reguestOrProgressId" => inspect(request_or_progress_id)
700-
}
696+
},
697+
send_telemetry: false
701698
end
702699

703700
state = %{
@@ -749,22 +746,30 @@ defmodule ElixirLS.Debugger.Server do
749746
config
750747

751748
{:DOWN, ^ref, :process, _pid, reason} ->
752-
if reason != :normal do
753-
message = "Launch request failed with reason\n" <> Exception.format_exit(reason)
749+
case reason do
750+
:normal ->
751+
:ok
754752

755-
Output.debugger_console(message)
753+
:shutdown ->
754+
:ok
756755

757-
exit_code = 1
758-
Output.send_event("exited", %{"exitCode" => exit_code})
759-
Output.send_event("terminated", %{"restart" => false})
756+
{:shutdown, _} ->
757+
:ok
760758

761-
raise ServerError,
762-
message: "launchError",
763-
format: message,
764-
variables: %{},
765-
show_user: true
766-
else
767-
raise "exit reason #{inspect(reason)} was not expected"
759+
_other ->
760+
message = "Launch request failed with reason\n" <> Exception.format_exit(reason)
761+
762+
Output.debugger_console(message)
763+
764+
exit_code = 1
765+
Output.send_event("exited", %{"exitCode" => exit_code})
766+
Output.send_event("terminated", %{"restart" => false})
767+
768+
raise ServerError,
769+
message: "launchError",
770+
format: message,
771+
variables: %{},
772+
show_user: true
768773
end
769774
end
770775

@@ -1138,7 +1143,8 @@ defmodule ElixirLS.Debugger.Server do
11381143
format: "frameId not found: {frameId}",
11391144
variables: %{
11401145
"frameId" => inspect(frame_id)
1141-
}
1146+
},
1147+
send_telemetry: false
11421148
end
11431149

11441150
{%{"scopes" => scopes}, state}
@@ -1319,10 +1325,9 @@ defmodule ElixirLS.Debugger.Server do
13191325
defp handle_request(request(_, command), %__MODULE__{}) when is_binary(command) do
13201326
raise ServerError,
13211327
message: "notSupported",
1322-
format: "Debugger request {command} is currently not supported",
1323-
variables: %{
1324-
"command" => command
1325-
}
1328+
format: "Debugger request #{command} is currently not supported",
1329+
variables: %{},
1330+
show_user: true
13261331
end
13271332

13281333
defp maybe_continue_other_processes(state, %{"singleThread" => true}) do
@@ -1424,7 +1429,8 @@ defmodule ElixirLS.Debugger.Server do
14241429
format: "pid no longer paused: {pid}",
14251430
variables: %{
14261431
"pid" => inspect(pid)
1427-
}
1432+
},
1433+
send_telemetry: false
14281434
end
14291435
end)
14301436
|> Enum.reverse()
@@ -1514,7 +1520,8 @@ defmodule ElixirLS.Debugger.Server do
15141520
raise ServerError,
15151521
message: "argumentError",
15161522
format: "Unable to find frame {frameId}",
1517-
variables: %{"frameId" => frame_id}
1523+
variables: %{"frameId" => frame_id},
1524+
send_telemetry: false
15181525
end
15191526
end
15201527

@@ -1535,7 +1542,8 @@ defmodule ElixirLS.Debugger.Server do
15351542
format: "variablesReference not found: {variablesReference}",
15361543
variables: %{
15371544
"variablesReference" => inspect(var_id)
1538-
}
1545+
},
1546+
send_telemetry: false
15391547

15401548
other ->
15411549
other

0 commit comments

Comments
 (0)