File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ defmodule Access do
60
60
end
61
61
end
62
62
63
+ def fetch ( list , key ) when is_list ( list ) do
64
+ raise ArgumentError ,
65
+ "the Access calls for keywords expect the key to be an atom, got: " <> inspect ( key )
66
+ end
67
+
63
68
def fetch ( nil , _key ) do
64
69
:error
65
70
end
Original file line number Diff line number Diff line change @@ -36,8 +36,9 @@ defmodule AccessTest do
36
36
assert Access . fetch ( [ foo: :bar ] , :foo ) == { :ok , :bar }
37
37
assert Access . fetch ( [ foo: :bar ] , :bar ) == :error
38
38
39
- assert_raise FunctionClauseError , fn ->
40
- Access . fetch ( [ { "foo" , :bar } ] , "foo" )
39
+ msg = ~r/ the Access calls for keywords expect the key to be an atom/
40
+ assert_raise ArgumentError , msg , fn ->
41
+ Access . fetch ( [ ] , "foo" )
41
42
end
42
43
43
44
assert Access . get ( [ foo: :bar ] , :foo ) == :bar
You can’t perform that action at this time.
0 commit comments