Improve error message
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user