Improve error message

This commit is contained in:
José Valim
2020-08-22 20:46:40 +02:00
parent 273a929001
commit 46ff8ccbc4
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -727,7 +727,7 @@ defmodule ArgumentError do
not is_atom(module) and is_atom(function) and args == [] ->
"you attempted to apply #{inspect(function)} on #{inspect(module)}. " <>
"If you are using apply/3, make sure the module is an atom. " <>
"If you are using the dot syntax, such as map.field or module.function, " <>
"If you are using the dot syntax, such as map.field or module.function(), " <>
"make sure the left side of the dot is an atom or a map"
not is_atom(module) ->
@@ -986,7 +986,7 @@ defmodule UndefinedFunctionError do
end
defp hint(nil, _function, 0, _loaded?) do
". If you are using the dot syntax, such as map.field or module.function, " <>
". If you are using the dot syntax, such as map.field or module.function(), " <>
"make sure the left side of the dot is an atom or a map"
end
+3 -3
View File
@@ -414,12 +414,12 @@ defmodule ExceptionTest do
assert blame_message([], & &1.foo) ==
"you attempted to apply :foo on []. If you are using apply/3, make sure " <>
"the module is an atom. If you are using the dot syntax, such as " <>
"map.field or module.function, make sure the left side of the dot is an atom or a map"
"map.field or module.function(), make sure the left side of the dot is an atom or a map"
assert blame_message([], &apply(&1, :foo, [])) ==
"you attempted to apply :foo on []. If you are using apply/3, make sure " <>
"the module is an atom. If you are using the dot syntax, such as " <>
"map.field or module.function, make sure the left side of the dot is an atom or a map"
"map.field or module.function(), make sure the left side of the dot is an atom or a map"
assert blame_message([], &apply(Kernel, &1, [1, 2])) ==
"you attempted to apply [] on module Kernel. Functions (the second argument of apply) must always be an atom"
@@ -464,7 +464,7 @@ defmodule ExceptionTest do
test "annotates undefined function clause error with nil hints" do
assert blame_message(nil, & &1.foo) ==
"function nil.foo/0 is undefined. If you are using the dot syntax, " <>
"such as map.field or module.function, make sure the left side of the dot is an atom or a map"
"such as map.field or module.function(), make sure the left side of the dot is an atom or a map"
end
test "annotates key error with suggestions if keys are atoms" do