With try/catch
it's generally considered incorrect to throw a string or other random object. You're supposed to construct a new Error and throw that instead.
Does this also apply to rejected promises?
With try/catch
it's generally considered incorrect to throw a string or other random object. You're supposed to construct a new Error and throw that instead.
Does this also apply to rejected promises?
The spec says, regarding the argument to reject
:
Typically it will be an Error object.
So it's expected that it will be an Error
, but it's not essential. Use whatever is semantically correct in your situation.