Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/elixir/lib/exception.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,11 @@ defmodule MatchError do

@impl true
def message(exception) do
"no match of right hand side value: #{inspect(exception.term)}"
"""
no match of right hand side value:

#{inspect(exception.term, pretty: true, limit: :infinity)}
Copy link
Member

Choose a reason for hiding this comment

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

We can pretty print but we should not set it to infinity. Given this goes to production logs, it can have a pretty negative impact.

"""
end
end

Expand Down
12 changes: 8 additions & 4 deletions lib/elixir/test/elixir/kernel/raise_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -450,16 +450,20 @@ defmodule Kernel.RaiseTest do
end

test "badmatch error" do
x = :example

result =
try do
^x = Process.get(:unused, 0)
[] = Range.to_list(1000_000..1_000_009)
rescue
x in [MatchError] -> Exception.message(x)
end

assert result == "no match of right hand side value: 0"
assert result ==
"""
no match of right hand side value:

[1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007,
1000008, 1000009]
"""
end

test "bad key error" do
Expand Down