summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@dashbit.co>2023-05-07 00:33:44 +0200
committerJosé Valim <jose.valim@dashbit.co>2023-05-07 00:33:44 +0200
commit8c69850adf67e9efa0070102ec53f50191138e5e (patch)
treead332964c275a8dc01d58857630eac92c62237d2
parentcf0d45401c761a284657a584b5bd3c9d6931f7f5 (diff)
downloadelixir-8c69850adf67e9efa0070102ec53f50191138e5e.tar.gz
Always show maps as multiline if they cannot fit a single line
-rw-r--r--lib/elixir/lib/exception.ex2
-rw-r--r--lib/elixir/test/elixir/exception_test.exs4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/elixir/lib/exception.ex b/lib/elixir/lib/exception.ex
index e61067b13..49e0e2590 100644
--- a/lib/elixir/lib/exception.ex
+++ b/lib/elixir/lib/exception.ex
@@ -1665,7 +1665,7 @@ defmodule ErlangError do
def normalize({:badkey, key, term}, _stacktrace) do
message =
- "key #{inspect(key)} not found in: #{inspect(term)}. " <>
+ "key #{inspect(key)} not found in: #{inspect(term, pretty: true, limit: :infinity)}\n\n" <>
"If you are using the dot syntax, such as map.field, " <>
"make sure the left-hand side of the dot is a map"
diff --git a/lib/elixir/test/elixir/exception_test.exs b/lib/elixir/test/elixir/exception_test.exs
index 8ab46e3cf..030b68cce 100644
--- a/lib/elixir/test/elixir/exception_test.exs
+++ b/lib/elixir/test/elixir/exception_test.exs
@@ -643,12 +643,12 @@ defmodule ExceptionTest do
test "annotates undefined key error with nil hints" do
assert blame_message(nil, & &1.foo) ==
- "key :foo not found in: nil. If you are using the dot syntax, " <>
+ "key :foo not found in: nil\n\nIf you are using the dot syntax, " <>
"such as map.field, make sure the left-hand side of the dot is a map"
# we use `Code.eval_string/1` to escape the formatter and warnings
assert blame_message("nil.foo", &Code.eval_string/1) ==
- "key :foo not found in: nil. If you are using the dot syntax, " <>
+ "key :foo not found in: nil\n\nIf you are using the dot syntax, " <>
"such as map.field, make sure the left-hand side of the dot is a map"
end