Promise.reject Function (Promise)

Creates a new rejected promise with a result equal to the passed in argument.

Syntax

Promise.reject(r);  

Parameters

r
Required. The reason why the promise was rejected.

Remarks

The error handling function of the then or catch method runs when the rejected promise is returned.

Example

var p = Promise.reject('failure');  
p.catch(function(result) {  
    console.log(result);  
});  

// Output:  
// failure  

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.

See Also

Promise Object