Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fixed pagination error #9243

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/server/models/plugins/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// Extends Bookshelf.Model with a `fetchPage` method. Handles everything to do with paginated requests.
var _ = require('lodash'),
errors = require('../../errors'),
i18n = require('../../i18n'),
defaults,
paginationUtils,
pagination;
Expand Down Expand Up @@ -189,6 +191,14 @@ pagination = function pagination(bookshelf) {
collection: fetchResult,
pagination: paginationUtils.formatResponse(countResult[0] ? countResult[0].aggregate : 0, options)
};
})
.catch(function (err) {
// e.g. offset/limit reached max allowed integer value
if (err.errno === 20 || err.errno === 1064) {
throw new errors.NotFoundError({message: i18n.t('errors.errors.pageNotFound')});
}

throw err;
});
});
}
Expand Down