This bit of code
this.loadingPromise.then(function(data) {
console.log('success');
}.bind(this));
doesn't have a catch, so the error is really not caught
Promises
var A = {
loadingPromise: null,
loadingPromiseFail: null,
loadingPromiseResolver: null,
init: function() {
this.loadingPromise = new Promise(
function(resolve, fail) {
this.loadingPromiseResolver = resolve;
this.loadingPromiseFail = fail;
}.bind(this)
);
this.loadingPromise.then(function(data) {
console.log('success');
}.bind(this)).catch(function(e, x) {
console.log('error', e);
}.bind(this));
},
doSomething: function() {
setTimeout(function() {
this.loadingPromiseFail('404');
}.bind(this), 1000);
}
}
A.init();
A.doSomething();
https://jsfiddle.net/4g7yj38b/7/
, .then( .catch) Promise... "" , .catch "", , .