Skip to content

Commit 4b36637

Browse files
committed
Do not send telemetry for common errors
improve user messages
1 parent 135447c commit 4b36637

File tree

1 file changed

+25
-31
lines changed
  • apps/elixir_ls_debugger/lib/debugger

1 file changed

+25
-31
lines changed

apps/elixir_ls_debugger/lib/debugger/server.ex

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -985,23 +985,14 @@ defmodule ElixirLS.Debugger.Server do
985985
message: "invalidRequest",
986986
format: "Cannot pause process when running with no debug",
987987
variables: %{},
988+
send_telemetry: false,
988989
show_user: true
989990
end
990991

991992
defp handle_request(pause_req(_, thread_id), state = %__MODULE__{}) do
992-
pid = state.thread_ids_to_pids[thread_id]
993+
pid = get_pid_by_thread_id!(state, thread_id, true)
993994

994-
if pid do
995-
:int.attach(pid, build_attach_mfa(:paused))
996-
else
997-
raise ServerError,
998-
message: "invalidArgument",
999-
format: "threadId not found: {threadId}",
1000-
variables: %{
1001-
"threadId" => inspect(thread_id)
1002-
},
1003-
show_user: true
1004-
end
995+
:int.attach(pid, build_attach_mfa(:paused))
1005996

1006997
{%{}, state}
1007998
end
@@ -1010,7 +1001,7 @@ defmodule ElixirLS.Debugger.Server do
10101001
request(_, "stackTrace", %{"threadId" => thread_id} = args),
10111002
state = %__MODULE__{}
10121003
) do
1013-
pid = get_pid_by_thread_id!(state, thread_id)
1004+
pid = get_pid_by_thread_id!(state, thread_id, false)
10141005

10151006
case state.paused_processes[pid] do
10161007
%PausedProcess{} = paused_process ->
@@ -1050,7 +1041,8 @@ defmodule ElixirLS.Debugger.Server do
10501041
format: "process not paused: {threadId}",
10511042
variables: %{
10521043
"threadId" => inspect(thread_id)
1053-
}
1044+
},
1045+
send_telemetry: false
10541046
end
10551047
end
10561048

@@ -1211,7 +1203,7 @@ defmodule ElixirLS.Debugger.Server do
12111203
end
12121204

12131205
defp handle_request(continue_req(_, thread_id) = args, state = %__MODULE__{}) do
1214-
pid = get_pid_by_thread_id!(state, thread_id)
1206+
pid = get_pid_by_thread_id!(state, thread_id, true)
12151207

12161208
state =
12171209
case state.dbg_session do
@@ -1235,7 +1227,7 @@ defmodule ElixirLS.Debugger.Server do
12351227
end
12361228

12371229
defp handle_request(next_req(_, thread_id) = args, state = %__MODULE__{}) do
1238-
pid = get_pid_by_thread_id!(state, thread_id)
1230+
pid = get_pid_by_thread_id!(state, thread_id, true)
12391231

12401232
state =
12411233
if match?({^pid, _ref}, state.dbg_session) do
@@ -1255,7 +1247,7 @@ defmodule ElixirLS.Debugger.Server do
12551247
end
12561248

12571249
defp handle_request(step_in_req(_, thread_id) = args, state = %__MODULE__{}) do
1258-
pid = get_pid_by_thread_id!(state, thread_id)
1250+
pid = get_pid_by_thread_id!(state, thread_id, true)
12591251

12601252
validate_dbg_pid!(state, pid, "stepIn")
12611253

@@ -1270,7 +1262,7 @@ defmodule ElixirLS.Debugger.Server do
12701262
end
12711263

12721264
defp handle_request(step_out_req(_, thread_id) = args, state = %__MODULE__{}) do
1273-
pid = get_pid_by_thread_id!(state, thread_id)
1265+
pid = get_pid_by_thread_id!(state, thread_id, true)
12741266

12751267
validate_dbg_pid!(state, pid, "stepOut")
12761268

@@ -1378,15 +1370,17 @@ defmodule ElixirLS.Debugger.Server do
13781370
:ok
13791371
end
13801372

1381-
defp get_pid_by_thread_id!(state = %__MODULE__{}, thread_id) do
1373+
defp get_pid_by_thread_id!(state = %__MODULE__{}, thread_id, show_message_on_error?) do
13821374
case state.thread_ids_to_pids[thread_id] do
13831375
nil ->
13841376
raise ServerError,
13851377
message: "invalidArgument",
1386-
format: "threadId not found: {threadId}",
1378+
format: "Unable to find process pid for DAP threadId {threadId}",
13871379
variables: %{
13881380
"threadId" => inspect(thread_id)
1389-
}
1381+
},
1382+
send_telemetry: false,
1383+
show_user: show_message_on_error?
13901384

13911385
pid ->
13921386
pid
@@ -1430,7 +1424,7 @@ defmodule ElixirLS.Debugger.Server do
14301424
{:error, :not_paused} ->
14311425
raise ServerError,
14321426
message: "runtimeError",
1433-
format: "pid no longer paused: {pid}",
1427+
format: "process with pid {pid} is not paused",
14341428
variables: %{
14351429
"pid" => inspect(pid)
14361430
},
@@ -1638,7 +1632,7 @@ defmodule ElixirLS.Debugger.Server do
16381632
raise ServerError,
16391633
message: "argumentError",
16401634
format:
1641-
"invalid `projectDir` in launch config. Expected string or nil, got #{inspect(project_dir)}",
1635+
"Invalid `projectDir` in launch config. Expected string or nil, got #{inspect(project_dir)}",
16421636
variables: %{},
16431637
send_telemetry: false,
16441638
show_user: true
@@ -1662,7 +1656,7 @@ defmodule ElixirLS.Debugger.Server do
16621656
raise ServerError,
16631657
message: "argumentError",
16641658
format:
1665-
"invalid `taskArgs` in launch config. Expected string or nil, got #{inspect(task)}",
1659+
"Invalid `taskArgs` in launch config. Expected string or nil, got #{inspect(task)}",
16661660
variables: %{},
16671661
send_telemetry: false,
16681662
show_user: true
@@ -1674,7 +1668,7 @@ defmodule ElixirLS.Debugger.Server do
16741668
raise ServerError,
16751669
message: "argumentError",
16761670
format:
1677-
"invalid `taskArgs` in launch config. Expected list of strings or nil, got #{inspect(task_args)}",
1671+
"Invalid `taskArgs` in launch config. Expected list of strings or nil, got #{inspect(task_args)}",
16781672
variables: %{},
16791673
send_telemetry: false,
16801674
show_user: true
@@ -1765,7 +1759,7 @@ defmodule ElixirLS.Debugger.Server do
17651759
raise ServerError,
17661760
message: "argumentError",
17671761
format:
1768-
"invalid `excludeModules` in launch config. Expected list of strings or nil, got #{inspect(exclude_module_names)}",
1762+
"Invalid `excludeModules` in launch config. Expected list of strings or nil, got #{inspect(exclude_module_names)}",
17691763
variables: %{},
17701764
send_telemetry: false,
17711765
show_user: true
@@ -1788,7 +1782,7 @@ defmodule ElixirLS.Debugger.Server do
17881782
raise ServerError,
17891783
message: "argumentError",
17901784
format:
1791-
"invalid `requireFiles` in launch config. Expected list of strings or nil, got #{inspect(required_files)}",
1785+
"Invalid `requireFiles` in launch config. Expected list of strings or nil, got #{inspect(required_files)}",
17921786
variables: %{},
17931787
send_telemetry: false,
17941788
show_user: true
@@ -1803,7 +1797,7 @@ defmodule ElixirLS.Debugger.Server do
18031797
raise ServerError,
18041798
message: "argumentError",
18051799
format:
1806-
"invalid `debugInterpretModulesPatterns` in launch config. Expected list of strings or nil, got #{inspect(interpret_modules_patterns)}",
1800+
"Invalid `debugInterpretModulesPatterns` in launch config. Expected list of strings or nil, got #{inspect(interpret_modules_patterns)}",
18071801
variables: %{},
18081802
send_telemetry: false,
18091803
show_user: true
@@ -1847,7 +1841,7 @@ defmodule ElixirLS.Debugger.Server do
18471841
raise ServerError,
18481842
message: "argumentError",
18491843
format:
1850-
"invalid `env` in launch configuration. Expected a map with string key value pairs, got #{inspect(env)}",
1844+
"Invalid `env` in launch configuration. Expected a map with string key value pairs, got #{inspect(env)}",
18511845
variables: %{},
18521846
send_telemetry: false,
18531847
show_user: true
@@ -1862,7 +1856,7 @@ defmodule ElixirLS.Debugger.Server do
18621856
raise ServerError,
18631857
message: "argumentError",
18641858
format:
1865-
"invalid `env` in launch configuration. Expected a map with string key value pairs, got #{inspect(env)}",
1859+
"Invalid `env` in launch configuration. Expected a map with string key value pairs, got #{inspect(env)}",
18661860
variables: %{},
18671861
send_telemetry: false,
18681862
show_user: true
@@ -1878,7 +1872,7 @@ defmodule ElixirLS.Debugger.Server do
18781872
raise ServerError,
18791873
message: "argumentError",
18801874
format:
1881-
"invalid `stackTraceMode` in launch configuration. Must be `all`, `no_tail` or `false`, got #{inspect(mode)}",
1875+
"Invalid `stackTraceMode` in launch configuration. Must be `all`, `no_tail` or `false`, got #{inspect(mode)}",
18821876
variables: %{},
18831877
send_telemetry: false,
18841878
show_user: true

0 commit comments

Comments
 (0)