Closed marijaselakovic closed 5 months ago
Throwing a TypeError
seems more informative than rejecting with false
to me. There have been several (dozens and dozens) of conversations about throwing sync Errors versus returning (async) rejections. Most of these discussions have concluded (iirc) that coding errors (rather than runtime errors) should throw sync.
Providing a non-function as a handler parameter seems like a coding error, doesn't it?
Except, perhaps, in very generic code, but this is an edge case.
Hello,
You should include the type check on catch handler because if a handler is not a function, the catch method throws the TypeError
For example, check the following code:
The second argument is non-function value and in this case the TypeError is thrown becuase method call can't be called on a non-function object.