From 63a0c39a00d0bd4297554a18e93300bf41e9a5db Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Tue, 1 Dec 2020 14:01:26 +0100 Subject: [PATCH] [scraper] simplifies nyaa 404 error message --- scraper/scrapers/nyaapantsu/nyaa_pantsu_api.js | 8 +++++++- scraper/scrapers/nyaasi/nyaa_si_api.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scraper/scrapers/nyaapantsu/nyaa_pantsu_api.js b/scraper/scrapers/nyaapantsu/nyaa_pantsu_api.js index a7de428..d390a99 100644 --- a/scraper/scrapers/nyaapantsu/nyaa_pantsu_api.js +++ b/scraper/scrapers/nyaapantsu/nyaa_pantsu_api.js @@ -23,7 +23,13 @@ function torrent(torrentId) { } return pantsu.infoRequest(torrentId) - .then(result => parseTorrent(result)); + .then(result => parseTorrent(result)) + .catch(error => { + if (error.statusCode && error.statusCode === 404) { + return Promise.reject(new Error(`404: [${torrentId}] not found on NyaaPantsu`)); + } + return Promise.reject(error); + }); } function search(query) { diff --git a/scraper/scrapers/nyaasi/nyaa_si_api.js b/scraper/scrapers/nyaasi/nyaa_si_api.js index 2bb3be1..36e11f1 100644 --- a/scraper/scrapers/nyaasi/nyaa_si_api.js +++ b/scraper/scrapers/nyaasi/nyaa_si_api.js @@ -24,7 +24,13 @@ function torrent(torrentId) { return si.infoRequest(torrentId) .then(result => parseTorrent(result)) - .then(result => ({ ...result, torrentId })); + .then(result => ({ ...result, torrentId })) + .catch(error => { + if (error.statusCode && error.statusCode === 404) { + return Promise.reject(new Error(`404: [${torrentId}] not found on NyaaSi`)); + } + return Promise.reject(error); + }); } function search(query) {