Skip to content
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

include crash_reason in translator #9

Merged
merged 3 commits into from Jan 2, 2019

Conversation

mitchellhenke
Copy link
Contributor

I wasn't sure on the odds of this being accepted, as I haven't seen including the error_reason key outside of core, and it does have some special considerations: https://github.com/elixir-lang/elixir/blob/master/lib/logger/lib/logger/backends/console.ex#L195

The goal is to be able to access more structured error information through Logger, similar to elixir-lang/elixir#7841

@josevalim
Copy link
Member

We would love to accept this but unfortunately it requires recent Elixir version. Maybe we should check the Elixir version before returning it?

@mitchellhenke
Copy link
Contributor Author

ohhhhh, yeah. is checking at runtime fine?

if non_500_exception?(reason) do
:skip
else
if Version.match?(System.version(), "~> 1.6") do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do this:

if Version.match?(System.version(), "~> 1.6") do
  defp ok(message, metadata) do
    {:ok, message, metadata}
  end
else
  defp ok(message, _metadata) do
    {:ok, message}
  end
end

And then we do:

ok(
  [
    inspect(pid),
    " running ",
    inspect(mod),
    extra,
    " terminated\n",
    conn_info(min_level, conn)
    | Exception.format(:exit, reason, [])
 ],
 [crash_reason: reason]
)

The advantage is then that we won't have to rewrite whole functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

things got weird with github being down for a bit, but I've amended the commit for excluding metadata

@josevalim josevalim merged commit 6513e38 into elixir-plug:master Jan 2, 2019
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants