From 4122f6e5aee70da5f954759332362e9783dc7ca1 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 25 Jun 2020 12:33:54 -0400 Subject: [PATCH] check out ouf bounds --- services/gunDB/contact-api/getters/wall.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/gunDB/contact-api/getters/wall.js b/services/gunDB/contact-api/getters/wall.js index 384e8dbe..dd40ef0d 100644 --- a/services/gunDB/contact-api/getters/wall.js +++ b/services/gunDB/contact-api/getters/wall.js @@ -23,6 +23,8 @@ const getWallTotalPages = async () => { /** * @param {number} page + * @throws {TypeError} + * @throws {RangeError} * @returns {Promise} */ const getWallPage = async page => { @@ -37,6 +39,10 @@ const getWallPage = async page => { const actualPageIdx = page < 0 ? totalPages + (page + 1) : page - 1 + if (actualPageIdx > totalPages - 1) { + throw new RangeError(`Requested a page out of bounds`) + } + /** * @type {Common.SchemaTypes.WallPage} */