Skip to content

Commit 4ce85d3

Browse files
committed
Simplify markdown rendering of debugger exceptions
One of the most common use cases of the markdown version is to feed it to LLMs and both code and headers make it too verbose.
1 parent 1123f63 commit 4ce85d3

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

lib/plug/templates/debugger.md.eex

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,6 @@ Exception:
44

55
<%= String.replace(@formatted, "\n", "\n ") %>
66

7-
Code:
8-
<%= for frame <- @frames do %>
9-
`<%= h frame.file %>`
10-
<%= if (snippet = frame.snippet) && snippet != [] do %>
11-
<%= for {index, line, highlight} <- snippet do %><%= if highlight do %><%= h index %>> <% else %><%= h index %> <% end %><%= h String.trim_trailing(line) %>
12-
<% end %><% else %>
13-
No code available.
14-
<% end %><%= if frame.args do %>
15-
Called with <%= length(frame.args) %> arguments
16-
17-
<%= for arg <- frame.args do %>* `<%= h inspect arg %>`
18-
<% end %><% end %><%= if frame.clauses do %><% {min, max, clauses} = frame.clauses %>
19-
Attempted function clauses (showing <%= min %> out of <%= max %>)
20-
21-
<%= for clause <- clauses do %> <%= clause %>
22-
<% end %>
23-
<% end %><% end %>
24-
257
## Connection details
268

279
### Params
@@ -33,10 +15,6 @@ Code:
3315
* URI: <%= url(@conn) %>
3416
* Query string: <%= @conn.query_string %>
3517

36-
### Headers
37-
<%= for {key, value} <- Enum.sort(@conn.req_headers) do %>
38-
* <%= key %>: <%= value %><% end %>
39-
4018
### Session
4119

4220
<%= inspect(@session) %>

test/plug/debugger_test.exs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -402,22 +402,6 @@ defmodule Plug.DebuggerTest do
402402
assert conn.resp_body =~ "unsupported media type foo/bar"
403403
end
404404

405-
test "renders bad match attempted arguments" do
406-
conn =
407-
conn(:get, "/bad_match")
408-
|> put_req_header("accept", "text/markdown")
409-
|> put_resp_header("content-security-policy", "abcdef")
410-
411-
capture_log(fn -> assert_raise(FunctionClauseError, fn -> Router.call(conn, []) end) end)
412-
{_status, _headers, body} = sent_resp(conn)
413-
414-
assert body =~ "# FunctionClauseError at GET /bad_match"
415-
assert body =~ "Code:\n"
416-
assert body =~ " Called with 2 arguments"
417-
assert body =~ " * `:six`"
418-
assert body =~ " * `:one`"
419-
end
420-
421405
test "render actions when an implementation of `Plug.Exception` has it" do
422406
[%{label: action_label}] = Plug.Exception.actions(%ActionableError{})
423407

0 commit comments

Comments
 (0)