-
Notifications
You must be signed in to change notification settings - Fork 591
Proposal - Pretty print error structs in debugger page #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It feels like we should just format the whole error message as |
Do you mean the error message from the original code? 🤔 The problem here is that |
Let’s change Elixir to use pretty for this message and also change Plug to use code style for the error message :) |
Gotcha. I can send a PR to Elixir and then update this one. |
to pretty print KeyError message, and improve layout styling.
lib/plug/templates/debugger.html.eex
Outdated
<h5 class="struct"> | ||
<%= h @title %> | ||
<small>at <%= h method(@conn) %></small> | ||
<small class="path"><%= h @conn.request_path %></small> | ||
</h5> | ||
<h1 class="title"><%= h headline %></h1> | ||
<%= for detail <- details do %> | ||
<code class="headline"><pre><%= h @headline %></pre></code> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using <pre>
to represent multi lines as noted here https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code#notes
I think we can keep the style closer to what you had: grey and smaller font. :) |
For all error messages like the |
Perfect. Let's do said changes and for all error messages. :) |
@@ -146,25 +145,6 @@ | |||
font-weight: 400; | |||
} | |||
|
|||
.exception-info > .title { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed because the default 1em
font looks good across all sizes.
lib/plug/debugger.ex
Outdated
@@ -187,6 +187,7 @@ defmodule Plug.Debugger do | |||
session = maybe_fetch_session(conn) | |||
params = maybe_fetch_query_params(conn) | |||
{title, message} = info(kind, reason) | |||
[headline | details] = String.split(message, "\n\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we no longer need to split between headline and details, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather just always format everything as code. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, done 👍🏻
💚 💙 💜 💛 ❤️ |
I couldn't find such proposal in past issues/PRs so this one is a simple PoC to gather feedback if that's a good idea or not.
In short, currently the debugger page looks like this:
And the idea is to improve UX by displaying this:
Notes:
Exception.message/1
seems okay to deal with some exceptions but it could get out of sync with Elixir stdlib if wording changes.