[scraper] simplifies nyaa 404 error message

This commit is contained in:
TheBeastLT
2020-12-01 14:01:26 +01:00
parent 160dafe870
commit 63a0c39a00
2 changed files with 14 additions and 2 deletions

View File

@@ -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) {

View File

@@ -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) {