Fixed some promises not handling errors

This commit is contained in:
Marcin Kurczewski 2014-11-03 20:42:10 +01:00
parent e57de564d9
commit 752af358df
4 changed files with 25 additions and 13 deletions

View file

@ -296,6 +296,7 @@ App.Controls.TagInput = function($underlyingInput) {
attachTagsToSuggestionList($siblings.find('ul'), suggestions);
$siblings.slideDown('fast');
}
}).fail(function() {
});
}

View file

@ -51,6 +51,9 @@ App.Presenters.PostListPresenter = function(
function() {
reinit(params, function() {});
});
}).fail(function() {
console.log(arguments);
loaded();
});
jQuery(window).on('resize', windowResized);

View file

@ -109,6 +109,7 @@ App.Presenters.PostPresenter = function(
$prevPost.removeAttr('href');
keyboard.unbind('d');
}
}).fail(function() {
});
}

View file

@ -27,7 +27,11 @@ App.Services.PostsAroundCalculator = function(_, promise, util, pager) {
getLinkToPostAround(postIds, position, query.page, 1))
.then(function(nextPostUrl, prevPostUrl) {
resolve(nextPostUrl, prevPostUrl);
}).fail(function() {
reject();
});
}).fail(function() {
reject();
});
});
}
@ -41,20 +45,23 @@ App.Services.PostsAroundCalculator = function(_, promise, util, pager) {
resolve(url);
} else if (page + direction >= 1) {
pager.setPage(page + direction);
promise.wait(pager.retrieveCached()).then(function(response) {
if (response.entities.length) {
var post = direction === - 1 ?
_.last(response.entities) :
_.first(response.entities);
promise.wait(pager.retrieveCached())
.then(function(response) {
if (response.entities.length) {
var post = direction === - 1 ?
_.last(response.entities) :
_.first(response.entities);
var url = util.appendComplexRouteParam(
'#/post/' + post.id,
_.extend({page: page + direction}, pager.getSearchParams()));
resolve(url);
} else {
resolve(null);
}
});
var url = util.appendComplexRouteParam(
'#/post/' + post.id,
_.extend({page: page + direction}, pager.getSearchParams()));
resolve(url);
} else {
resolve(null);
}
}).fail(function() {
reject();
});
} else {
resolve(null);
}