Added logging of exceptions thrown by templates
(finally)
This commit is contained in:
parent
4d9fc51819
commit
0945ed64ee
1 changed files with 13 additions and 1 deletions
|
@ -2,6 +2,12 @@ var App = App || {};
|
||||||
|
|
||||||
App.Promise = function(_, jQuery, progress) {
|
App.Promise = function(_, jQuery, progress) {
|
||||||
|
|
||||||
|
function BrokenPromiseError(promiseId) {
|
||||||
|
this.name = 'BrokenPromiseError';
|
||||||
|
this.message = 'Broken promise (promise ID: ' + promiseId + ')';
|
||||||
|
}
|
||||||
|
BrokenPromiseError.prototype = new Error();
|
||||||
|
|
||||||
var active = [];
|
var active = [];
|
||||||
var promiseId = 0;
|
var promiseId = 0;
|
||||||
|
|
||||||
|
@ -17,6 +23,9 @@ App.Promise = function(_, jQuery, progress) {
|
||||||
active = _.without(active, promise.promiseId);
|
active = _.without(active, promise.promiseId);
|
||||||
progress.done();
|
progress.done();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!(e instanceof BrokenPromiseError)) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
progress.reset();
|
progress.reset();
|
||||||
}
|
}
|
||||||
}, function() {
|
}, function() {
|
||||||
|
@ -25,6 +34,9 @@ App.Promise = function(_, jQuery, progress) {
|
||||||
active = _.without(active, promise.promiseId);
|
active = _.without(active, promise.promiseId);
|
||||||
progress.done();
|
progress.done();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!(e instanceof BrokenPromiseError)) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
progress.reset();
|
progress.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -33,7 +45,7 @@ App.Promise = function(_, jQuery, progress) {
|
||||||
|
|
||||||
promise.always(function() {
|
promise.always(function() {
|
||||||
if (!_.contains(active, promise.promiseId)) {
|
if (!_.contains(active, promise.promiseId)) {
|
||||||
throw new Error('Broken promise (promise ID: ' + promise.promiseId + ')');
|
throw new BrokenPromiseError(promise.promiseId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue