Open warner opened 5 years ago
We could also add an optional second parameter, which, on error, is stringified and added to the message.
@warner slightly better error messages were added in v3.0.0. Do you think it solves this issue or should it remain open?
When
Nat()
rejects the argument, it throwsRangeError("not a safe integer")
. I'm finding it a bit frustrating that the error message doesn't tell me what is being rejected (RangeError("'undefined' is not a safe integer")
), and for debugging, I wind up needing to wrap theNat
call with:which kind of loses the succinctness of
Nat(thing)
.Would it be appropriate to change the error messages to include the stringification of the rejected non-natural-number?
OTOH, I can imagine some benefits to having a predictable (and string-matchable) error message. I don't know what the JS convention is on examining error objects.