A promise enters the rejected state when an asynchronous task fails: the promised value was not obtained, but the reason for failure is known. section 6.3.2
A promise becomes rejected when:
- Its reject function is called. section 6.3.2
- An unhandled exception occurs during promise handling. section 6.3.2
- It reaches this state, it cannot switch to fulfilled or another state. section 6.3.2
Choosing the failure callback
In the simple Hattori promise, calling reject(...) instead of resolve(...) sends handling to the second callback passed to then, the failure callback. section 6.3
Use the promise-state diagram to compare rejection with pending and fulfilled states. section 6.3.2
