map.LookupByNode reports unhelpful error when given a badly typed input #455
Labels
exp/novice
Someone with a little familiarity can pick up
good first issue
Good issue for new contributors
help wanted
Seeking public contribution on this issue
P3
Low: Not priority right now
See c252ec2#diff-01ef2f316335ee972d15e3ff4c13fc77f11790911033d21c03b5155f10284922R242
The method
LookupByNode
on map expects its argument to be a string. If a bad value such as a number is passed in, the error message is unclear as to the real problem. For example, whenmap.LookupByNode(basicnode.NewInt(3))
is called, the error isfunc called on wrong kind: "AsString" called on a int node (kind: int), but only makes sense on string
. This is because the parameter is coerced to a string and that error bubbles up to the caller. It would be better if the error were something likeLookupByNode needs a string parameter, got (kind: int)
, letting the caller know exactly what they are doing wrong.Many other methods on other types have similar issues.
The text was updated successfully, but these errors were encountered: