-
Notifications
You must be signed in to change notification settings - Fork 3.5k
pretty format terms in errors #14269
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
Changes from all commits
634a766
531ac72
f395f92
9a5c2b6
9c65685
fd7dd53
aaf1ae9
c05bd84
269d7f2
a334a3f
51d82cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -701,33 +701,69 @@ defmodule ExceptionTest do | |
| message = blame_message(%{first: nil, second: nil}, fn map -> map.firts end) | ||
|
|
||
| assert message == """ | ||
| key :firts not found in: %{first: nil, second: nil}. Did you mean: | ||
| key :firts not found in: | ||
|
|
||
| %{first: nil, second: nil} | ||
|
|
||
| Did you mean: | ||
|
|
||
| * :first | ||
| """ | ||
|
|
||
| message = blame_message(%{"first" => nil, "second" => nil}, fn map -> map.firts end) | ||
|
|
||
| assert message == "key :firts not found in: %{\"first\" => nil, \"second\" => nil}" | ||
| assert message == """ | ||
| key :firts not found in: | ||
|
|
||
| %{"first" => nil, "second" => nil}\ | ||
| """ | ||
|
|
||
| message = | ||
| blame_message(%{"first" => nil, "second" => nil}, fn map -> Map.fetch!(map, "firts") end) | ||
|
|
||
| assert message == "key \"firts\" not found in: %{\"first\" => nil, \"second\" => nil}" | ||
| assert message == | ||
| """ | ||
| key "firts" not found in: | ||
|
|
||
| %{"first" => nil, "second" => nil}\ | ||
| """ | ||
|
|
||
| message = | ||
| blame_message([first: nil, second: nil], fn kwlist -> Keyword.fetch!(kwlist, :firts) end) | ||
| blame_message( | ||
| [ | ||
| created_at: nil, | ||
| updated_at: nil, | ||
| deleted_at: nil, | ||
| started_at: nil, | ||
| finished_at: nil | ||
| ], | ||
| fn kwlist -> | ||
| Keyword.fetch!(kwlist, :inserted_at) | ||
| end | ||
| ) | ||
|
|
||
| assert message == """ | ||
| key :firts not found in: [first: nil, second: nil]. Did you mean: | ||
| key :inserted_at not found in: | ||
|
|
||
| * :first | ||
| [ | ||
| created_at: nil, | ||
| updated_at: nil, | ||
| deleted_at: nil, | ||
| started_at: nil, | ||
| finished_at: nil | ||
| ] | ||
|
|
||
| Did you mean: | ||
|
|
||
| * :created_at | ||
| * :finished_at | ||
| * :started_at | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also an issues: This is more natural imo - you first check the suggestion and then go to the printed structure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not change the order for now but we definitely need to fix the line breaking. |
||
| """ | ||
| end | ||
|
|
||
| test "annotates key error with suggestions for structs" do | ||
| message = blame_message(%URI{}, fn map -> map.schema end) | ||
| assert message =~ "key :schema not found in: %URI{" | ||
| assert message =~ "key :schema not found in:\n\n %URI{" | ||
| assert message =~ "Did you mean:" | ||
| assert message =~ "* :scheme" | ||
| end | ||
|
|
||
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.
We should mark it as @doc false. Preferably underscore it too.