elixir-plug / plug

Compose web applications with functions
https://hex.pm/packages/plug
Other
2.84k stars 582 forks source link

Proposal - Pretty print error structs in debugger page #1126

Closed leandrocp closed 1 year ago

leandrocp commented 1 year ago

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:

Screenshot 2023-01-06 at 1 53 48 PM

And the idea is to improve UX by displaying this:

Screenshot 2023-01-06 at 1 53 20 PM

Notes:

josevalim commented 1 year ago

It feels like we should just format the whole error message as <code>, because they are written with assumption they will be printed monospaced?

leandrocp commented 1 year ago

It feels like we should just format the whole error message as <code>, because they are written with assumption they will be printed monospaced?

Do you mean the error message from the original code? 🤔 The problem here is that Exception.message/1 does return a string with no line breaks, that's why I had to reformat as inspect(term, pretty: true, limit: :infinity)

josevalim commented 1 year ago

Let’s change Elixir to use pretty for this message and also change Plug to use code style for the error message :)

leandrocp commented 1 year ago

Gotcha. I can send a PR to Elixir and then update this one.

leandrocp commented 1 year ago

So that's how a simple message would like:

Screenshot 2023-01-06 at 4 10 54 PM

And how a long KeyError would like:

Screenshot 2023-01-06 at 4 11 57 PM Screenshot 2023-01-06 at 4 12 10 PM
josevalim commented 1 year ago

I think we can keep the style closer to what you had: grey and smaller font. :)

leandrocp commented 1 year ago

I think we can keep the style closer to what you had: grey and smaller font. :)

For all error messages like the MatchError example above? Because they all share the same style.

leandrocp commented 1 year ago

That's how it would like, grey and smaller font:

A regular exception:

Screenshot 2023-01-06 at 4 56 41 PM

And KeyError with pretty: true:

Screenshot 2023-01-06 at 4 57 09 PM
josevalim commented 1 year ago

Perfect. Let's do said changes and for all error messages. :)

josevalim commented 1 year ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart: