diff --git a/lib/routes/disqus/posts.js b/lib/routes/disqus/posts.js index 9368624cc6..ab1779e1ea 100644 --- a/lib/routes/disqus/posts.js +++ b/lib/routes/disqus/posts.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.disqus || !config.disqus.api_key) { - throw 'Disqus RSS is disabled due to the lack of relevant config'; + throw new Error('Disqus RSS is disabled due to the lack of relevant config'); } const forum = ctx.params.forum; diff --git a/lib/routes/fanfou/favorites.js b/lib/routes/fanfou/favorites.js index 589e8993ad..abeb4bb35e 100644 --- a/lib/routes/fanfou/favorites.js +++ b/lib/routes/fanfou/favorites.js @@ -3,7 +3,7 @@ const utils = require('./utils'); module.exports = async (ctx) => { if (!config.fanfou || !config.fanfou.consumer_key || !config.fanfou.consumer_secret || !config.fanfou.username || !config.fanfou.password) { - throw 'Fanfou RSS is disabled due to the lack of relevant config'; + throw new Error('Fanfou RSS is disabled due to the lack of relevant config'); } const uid = ctx.params.uid; diff --git a/lib/routes/fanfou/home-timeline.js b/lib/routes/fanfou/home-timeline.js index f5fc817ac1..94af0c2d8d 100644 --- a/lib/routes/fanfou/home-timeline.js +++ b/lib/routes/fanfou/home-timeline.js @@ -3,7 +3,7 @@ const utils = require('./utils'); module.exports = async (ctx) => { if (!config.fanfou || !config.fanfou.consumer_key || !config.fanfou.consumer_secret || !config.fanfou.username || !config.fanfou.password) { - throw 'Fanfou RSS is disabled due to the lack of relevant config'; + throw new Error('Fanfou RSS is disabled due to the lack of relevant config'); } const fanfou = await utils.getFanfou(); diff --git a/lib/routes/fanfou/public-timeline.js b/lib/routes/fanfou/public-timeline.js index c28df8ef2e..81d18f28e2 100644 --- a/lib/routes/fanfou/public-timeline.js +++ b/lib/routes/fanfou/public-timeline.js @@ -3,7 +3,7 @@ const utils = require('./utils'); module.exports = async (ctx) => { if (!config.fanfou || !config.fanfou.consumer_key || !config.fanfou.consumer_secret || !config.fanfou.username || !config.fanfou.password) { - throw 'Fanfou RSS is disabled due to the lack of relevant config'; + throw new Error('Fanfou RSS is disabled due to the lack of relevant config'); } const keyword = ctx.params.keyword; diff --git a/lib/routes/fanfou/user-timeline.js b/lib/routes/fanfou/user-timeline.js index a4e276a080..4f6d9d8611 100644 --- a/lib/routes/fanfou/user-timeline.js +++ b/lib/routes/fanfou/user-timeline.js @@ -3,7 +3,7 @@ const utils = require('./utils'); module.exports = async (ctx) => { if (!config.fanfou || !config.fanfou.consumer_key || !config.fanfou.consumer_secret || !config.fanfou.username || !config.fanfou.password) { - throw 'Fanfou RSS is disabled due to the lack of relevant config'; + throw new Error('Fanfou RSS is disabled due to the lack of relevant config'); } const uid = ctx.params.uid; diff --git a/lib/routes/gocomics/index.js b/lib/routes/gocomics/index.js index cc23c2a45f..39be145957 100644 --- a/lib/routes/gocomics/index.js +++ b/lib/routes/gocomics/index.js @@ -23,7 +23,7 @@ module.exports = async (ctx) => { let previous = $('.gc-deck--cta-0 a').attr('href'); if (!previous) { - throw `Comic Not Found - ${name}`; + throw new Error(`Comic Not Found - ${name}`); } while (items.length < limit) { diff --git a/lib/routes/lastfm/loved.js b/lib/routes/lastfm/loved.js index 56cbff0613..51ca36f9cb 100644 --- a/lib/routes/lastfm/loved.js +++ b/lib/routes/lastfm/loved.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.lastfm || !config.lastfm.api_key) { - throw 'Last.fm RSS is disabled due to the lack of relevant config'; + throw new Error('Last.fm RSS is disabled due to the lack of relevant config'); } const user = ctx.params.user; diff --git a/lib/routes/lastfm/recent.js b/lib/routes/lastfm/recent.js index 2a573d263a..02b17668ce 100644 --- a/lib/routes/lastfm/recent.js +++ b/lib/routes/lastfm/recent.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.lastfm || !config.lastfm.api_key) { - throw 'Last.fm RSS is disabled due to the lack of relevant config'; + throw new Error('Last.fm RSS is disabled due to the lack of relevant config'); } const user = ctx.params.user; diff --git a/lib/routes/lastfm/top.js b/lib/routes/lastfm/top.js index 675d4fc8bd..3ee3b7ee25 100644 --- a/lib/routes/lastfm/top.js +++ b/lib/routes/lastfm/top.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.lastfm || !config.lastfm.api_key) { - throw 'Last.fm RSS is disabled due to the lack of relevant config'; + throw new Error('Last.fm RSS is disabled due to the lack of relevant config'); } const country = ctx.params.country; diff --git a/lib/routes/miniflux/get-entries.js b/lib/routes/miniflux/get-entries.js index a9c1727a8c..bbd363de89 100644 --- a/lib/routes/miniflux/get-entries.js +++ b/lib/routes/miniflux/get-entries.js @@ -17,7 +17,7 @@ module.exports = async (ctx) => { const token = config.miniflux.token; if (!token) { - throw 'This RSS feed is disabled due to its incorrect configuration: the token is missing.'; + throw new Error('This RSS feed is disabled due to its incorrect configuration: the token is missing.'); } // In this function, var`mark`, `link`, and `limit`, `addFeedName` diff --git a/lib/routes/miniflux/get-feeds.js b/lib/routes/miniflux/get-feeds.js index dc3f21a9e6..7b8b3d98dc 100644 --- a/lib/routes/miniflux/get-feeds.js +++ b/lib/routes/miniflux/get-feeds.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const token = config.miniflux.token; if (!token) { - throw 'This RSS feed is disabled due to its incorrect configuration: the token is missing.'; + throw new Error('This RSS feed is disabled due to its incorrect configuration: the token is missing.'); } function set(item) { diff --git a/lib/v2/12306/index.js b/lib/v2/12306/index.js index 0fdfc03395..7b5cffd643 100644 --- a/lib/v2/12306/index.js +++ b/lib/v2/12306/index.js @@ -62,7 +62,7 @@ module.exports = async (ctx) => { }, }); if (response.data.data === undefined || response.data.data.length === 0) { - throw '没有找到相关车次,请检查参数是否正确'; + throw new Error('没有找到相关车次,请检查参数是否正确'); } const data = response.data.data.result; const map = response.data.data.map; diff --git a/lib/v2/163/music/playlist.js b/lib/v2/163/music/playlist.js index 722804899d..0a540137f7 100644 --- a/lib/v2/163/music/playlist.js +++ b/lib/v2/163/music/playlist.js @@ -5,7 +5,7 @@ const path = require('path'); module.exports = async (ctx) => { if (!config.ncm || !config.ncm.cookies) { - throw '163 Music RSS is disabled due to the lack of relevant config'; + throw new Error('163 Music RSS is disabled due to the lack of relevant config'); } const id = ctx.params.id; diff --git a/lib/v2/591/list.js b/lib/v2/591/list.js index 17012719c2..38eae088ef 100644 --- a/lib/v2/591/list.js +++ b/lib/v2/591/list.js @@ -30,7 +30,7 @@ async function getToken() { const csrfToken = $('meta[name="csrf-token"]').attr('content'); if (!csrfToken) { - throw 'CSRF token not found'; + throw new Error('CSRF token not found'); } return csrfToken; diff --git a/lib/v2/acfun/article.js b/lib/v2/acfun/article.js index a701298e6c..ac1acd15a3 100644 --- a/lib/v2/acfun/article.js +++ b/lib/v2/acfun/article.js @@ -35,13 +35,13 @@ const timeRangeEnum = new Set(['all', 'oneDay', 'threeDay', 'oneWeek', 'oneMonth module.exports = async (ctx) => { const { categoryId, sortType = 'createTime', timeRange = 'all' } = ctx.params; if (!categoryMap[categoryId]) { - throw `Invalid category Id: ${categoryId}`; + throw new Error(`Invalid category Id: ${categoryId}`); } if (!sortTypeEnum.has(sortType)) { - throw `Invalid sort type: ${sortType}`; + throw new Error(`Invalid sort type: ${sortType}`); } if (!timeRangeEnum.has(timeRange)) { - throw `Invalid time range: ${timeRange}`; + throw new Error(`Invalid time range: ${timeRange}`); } const url = `${baseUrl}/v/list${categoryId}/index.htm`; diff --git a/lib/v2/aisixiang/thinktank.js b/lib/v2/aisixiang/thinktank.js index 748e5bddf2..c0aadb2755 100644 --- a/lib/v2/aisixiang/thinktank.js +++ b/lib/v2/aisixiang/thinktank.js @@ -21,7 +21,7 @@ module.exports = async (ctx) => { .toArray() .filter((h) => (type ? $(h).text() === type : true)); if (!targetList) { - throw `Not found ${type} in ${id}: ${currentUrl}`; + throw new Error(`Not found ${type} in ${id}: ${currentUrl}`); } for (const l of targetList) { diff --git a/lib/v2/comicskingdom/index.js b/lib/v2/comicskingdom/index.js index eb94afd0e6..b5a5789e0f 100644 --- a/lib/v2/comicskingdom/index.js +++ b/lib/v2/comicskingdom/index.js @@ -22,7 +22,7 @@ module.exports = async (ctx) => { .map((el) => $(el).find('a').first().attr('href')); if (links.length === 0) { - throw `Comic Not Found - ${name}`; + throw new Error(`Comic Not Found - ${name}`); } const items = await Promise.all( links.map((link) => diff --git a/lib/v2/ehentai/favorites.js b/lib/v2/ehentai/favorites.js index eb814d5ef1..25097a65e8 100644 --- a/lib/v2/ehentai/favorites.js +++ b/lib/v2/ehentai/favorites.js @@ -2,7 +2,7 @@ const EhAPI = require('./ehapi'); module.exports = async (ctx) => { if (!EhAPI.has_cookie) { - throw 'Ehentai favorites RSS is disabled due to the lack of relevant config'; + throw new Error('Ehentai favorites RSS is disabled due to the lack of relevant config'); } const favcat = ctx.params.favcat ? Number.parseInt(ctx.params.favcat) : 0; const page = ctx.params.page; diff --git a/lib/v2/gdut/news.js b/lib/v2/gdut/news.js index 4c0257b27c..efe51b65ef 100644 --- a/lib/v2/gdut/news.js +++ b/lib/v2/gdut/news.js @@ -46,7 +46,7 @@ async function getCookie() { }).catch((e) => { if (e.statusCode === 302) { if (/UserLogin/.test(e.headers.location)) { - throw '新闻网登录失败'; + throw new Error('新闻网登录失败'); } } else { throw e; @@ -85,7 +85,7 @@ module.exports = async (ctx) => { }, }); } else if (/waf_verify/.test(e.headers.location)) { - throw '访问量过大,触发验证码'; + throw new Error('访问量过大,触发验证码'); } else { throw e; } diff --git a/lib/v2/github/follower.js b/lib/v2/github/follower.js index 3f8b7b1170..bbf29e81ac 100644 --- a/lib/v2/github/follower.js +++ b/lib/v2/github/follower.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.github || !config.github.access_token) { - throw 'GitHub follower RSS is disabled due to the lack of relevant config'; + throw new Error('GitHub follower RSS is disabled due to the lack of relevant config'); } const user = ctx.params.user; diff --git a/lib/v2/github/star.js b/lib/v2/github/star.js index d7c3dee5b6..ee573d2a19 100644 --- a/lib/v2/github/star.js +++ b/lib/v2/github/star.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.github || !config.github.access_token) { - throw 'GitHub star RSS is disabled due to the lack of relevant config'; + throw new Error('GitHub star RSS is disabled due to the lack of relevant config'); } const user = ctx.params.user; const repo = ctx.params.repo; diff --git a/lib/v2/github/starred-repos.js b/lib/v2/github/starred-repos.js index 2de70ad4a6..1483258b37 100644 --- a/lib/v2/github/starred-repos.js +++ b/lib/v2/github/starred-repos.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.github || !config.github.access_token) { - throw 'GitHub star RSS is disabled due to the lack of relevant config'; + throw new Error('GitHub star RSS is disabled due to the lack of relevant config'); } const user = ctx.params.user; diff --git a/lib/v2/gov/suzhou/news.js b/lib/v2/gov/suzhou/news.js index 2db4271555..d75d39322a 100644 --- a/lib/v2/gov/suzhou/news.js +++ b/lib/v2/gov/suzhou/news.js @@ -69,7 +69,7 @@ module.exports = async (ctx) => { title = '苏州市政府 - 民生资讯'; break; default: - throw 'pattern not matched'; + throw new Error('pattern not matched'); } if (apiUrl) { const response = await got(apiUrl); diff --git a/lib/v2/guokr/channel.js b/lib/v2/guokr/channel.js index 2889d3e991..67409142c3 100644 --- a/lib/v2/guokr/channel.js +++ b/lib/v2/guokr/channel.js @@ -23,7 +23,7 @@ module.exports = async (ctx) => { const items = response.data.result; if (items.length === 0) { - throw 'Unknown channel'; + throw new Error('Unknown channel'); } const channel_name = items[0].channels[0].name; diff --git a/lib/v2/lofter/user.js b/lib/v2/lofter/user.js index ad7d1d6393..fbd95c851a 100644 --- a/lib/v2/lofter/user.js +++ b/lib/v2/lofter/user.js @@ -28,7 +28,7 @@ module.exports = async (ctx) => { }); if (!response.data.response || response.data.response.posts.length === 0) { - throw 'Blog Not Found'; + throw new Error('Blog Not Found'); } const items = response.data.response.posts.map((item) => ({ diff --git a/lib/v2/manhuagui/subscribe.js b/lib/v2/manhuagui/subscribe.js index 2a01f0e20f..2671650c73 100644 --- a/lib/v2/manhuagui/subscribe.js +++ b/lib/v2/manhuagui/subscribe.js @@ -8,7 +8,7 @@ const web_url = 'https://www.manhuagui.com/user/book/shelf/1'; module.exports = async (ctx) => { if (!config.manhuagui || !config.manhuagui.cookie) { - throw 'manhuagui RSS is disabled due to the lack of relevant config'; + throw new Error('manhuagui RSS is disabled due to the lack of relevant config'); } const cookie = config.manhuagui.cookie; const response = await got({ diff --git a/lib/v2/mastodon/utils.js b/lib/v2/mastodon/utils.js index f042dd73a9..692a1abb33 100644 --- a/lib/v2/mastodon/utils.js +++ b/lib/v2/mastodon/utils.js @@ -114,7 +114,7 @@ async function getAccountIdByAcct(acct, ctx) { const accountData = search_response.data.accounts.filter((item) => item.acct === acctOnServer); if (accountData.length === 0) { - throw `acct ${acct} not found`; + throw new Error(`acct ${acct} not found`); } return accountData[0].id; }); diff --git a/lib/v2/mihoyo/bbs/cache.js b/lib/v2/mihoyo/bbs/cache.js index c0259a9ef8..6ed3647b39 100644 --- a/lib/v2/mihoyo/bbs/cache.js +++ b/lib/v2/mihoyo/bbs/cache.js @@ -4,7 +4,7 @@ const config = require('@/config').value; module.exports = { getUserFullInfo: (ctx, uid) => { if (!uid && !config.mihoyo.cookie) { - throw 'GetUserFullInfo is not available due to the absense of [Miyoushe Cookie]. Check relevant config tutorial'; + throw new Error('GetUserFullInfo is not available due to the absense of [Miyoushe Cookie]. Check relevant config tutorial'); } uid ||= ''; const key = 'mihoyo:user-full-info-uid-' + uid; diff --git a/lib/v2/mihoyo/bbs/timeline.js b/lib/v2/mihoyo/bbs/timeline.js index 3c7e84fc0d..5e580ff6f5 100644 --- a/lib/v2/mihoyo/bbs/timeline.js +++ b/lib/v2/mihoyo/bbs/timeline.js @@ -5,7 +5,7 @@ const { post2item } = require('./utils'); module.exports = async (ctx) => { if (!config.mihoyo.cookie) { - throw 'Miyoushe Timeline is not available due to the absense of [Miyoushe Cookie]. Check relevant config tutorial'; + throw new Error('Miyoushe Timeline is not available due to the absense of [Miyoushe Cookie]. Check relevant config tutorial'); } const page_size = ctx.query.limit || '20'; diff --git a/lib/v2/njust/cwc.js b/lib/v2/njust/cwc.js index 100d8a3cdf..d945908e1e 100644 --- a/lib/v2/njust/cwc.js +++ b/lib/v2/njust/cwc.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { const type = ctx.params.type ?? 'tzgg'; const info = map.get(type); if (!info) { - throw 'invalid type'; + throw new Error('invalid type'); } const id = info.id; const siteUrl = host + id + '/list.htm'; diff --git a/lib/v2/njust/dgxg.js b/lib/v2/njust/dgxg.js index 06d5048c60..f988ee7e3e 100644 --- a/lib/v2/njust/dgxg.js +++ b/lib/v2/njust/dgxg.js @@ -15,7 +15,7 @@ module.exports = async (ctx) => { const type = ctx.params.type ?? 'gstz'; const info = map.get(type); if (!info) { - throw 'invalid type'; + throw new Error('invalid type'); } const id = info.id; const siteUrl = host + id + '/list.htm'; diff --git a/lib/v2/njust/eo.js b/lib/v2/njust/eo.js index eb9379ccfb..6ef358a7da 100644 --- a/lib/v2/njust/eo.js +++ b/lib/v2/njust/eo.js @@ -21,7 +21,7 @@ module.exports = async (ctx) => { const type = ctx.params.type ?? 'tz'; let info = map.get(grade + type); if (!info) { - // throw 'invalid type'; + // throw new Error('invalid type'); info = { title: '', id: '/' + grade + '/' + type }; } const id = info.id; diff --git a/lib/v2/njust/eoe.js b/lib/v2/njust/eoe.js index bec1c1c95e..eebcb16b2e 100644 --- a/lib/v2/njust/eoe.js +++ b/lib/v2/njust/eoe.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { const type = ctx.params.type ?? 'tzgg'; const info = map.get(type); if (!info) { - throw 'invalid type'; + throw new Error('invalid type'); } const id = info.id; const siteUrl = host + id + '/list.htm'; diff --git a/lib/v2/njust/jwc.js b/lib/v2/njust/jwc.js index dec094d087..6053e115a1 100644 --- a/lib/v2/njust/jwc.js +++ b/lib/v2/njust/jwc.js @@ -16,7 +16,7 @@ module.exports = async (ctx) => { const type = ctx.params.type ?? 'xstz'; const info = map.get(type); if (!info) { - throw 'invalid type'; + throw new Error('invalid type'); } const id = info.id; const siteUrl = host + id + '/list.htm'; diff --git a/lib/v2/notion/database.js b/lib/v2/notion/database.js index 9dba63b974..e96035e7ec 100644 --- a/lib/v2/notion/database.js +++ b/lib/v2/notion/database.js @@ -12,7 +12,7 @@ const md = require('markdown-it')({ module.exports = async (ctx) => { if (!config.notion.key) { - throw 'Notion RSS is disabled due to the lack of NOTION_TOKEN(relevant config)'; + throw new Error('Notion RSS is disabled due to the lack of NOTION_TOKEN(relevant config)'); } const databaseId = ctx.params.databaseId; diff --git a/lib/v2/pianyuan/search.js b/lib/v2/pianyuan/search.js index 09b060dced..4f72607f0e 100644 --- a/lib/v2/pianyuan/search.js +++ b/lib/v2/pianyuan/search.js @@ -15,7 +15,7 @@ module.exports = async (ctx) => { .get() .map((a) => $(a).attr('href')); if (searchLinks.length === 0) { - throw 'pianyuan 搜索失败'; + throw new Error('pianyuan 搜索失败'); } const detailLinks = []; diff --git a/lib/v2/pianyuan/utils.js b/lib/v2/pianyuan/utils.js index 823db8cded..994a998504 100644 --- a/lib/v2/pianyuan/utils.js +++ b/lib/v2/pianyuan/utils.js @@ -47,7 +47,7 @@ async function getCookie(cache) { let py_loginauth = await cache.get(loginauth_key); if (!py_loginauth) { if (!config.pianyuan || !config.pianyuan.cookie) { - throw 'pianyuan is disabled due to the lack of relevant config'; + throw new Error('pianyuan is disabled due to the lack of relevant config'); } py_loginauth = config.pianyuan.cookie; } @@ -77,7 +77,7 @@ async function request(link, cache) { } } if (response.data.includes('会员登录后才能访问')) { - throw 'pianyuan Cookie已失效'; + throw new Error('pianyuan Cookie已失效'); } return response; } diff --git a/lib/v2/pixiv/bookmarks.js b/lib/v2/pixiv/bookmarks.js index 0d403b1852..3b9ebee956 100644 --- a/lib/v2/pixiv/bookmarks.js +++ b/lib/v2/pixiv/bookmarks.js @@ -7,14 +7,14 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.refreshToken) { - throw 'pixiv RSS is disabled due to the lack of relevant config'; + throw new Error('pixiv RSS is disabled due to the lack of relevant config'); } const id = ctx.params.id; const token = await getToken(ctx.cache.tryGet); if (!token) { - throw 'pixiv not login'; + throw new Error('pixiv not login'); } const [bookmarksResponse, userDetailResponse] = await Promise.all([getBookmarks(id, token), getUserDetail(id, token)]); diff --git a/lib/v2/pixiv/illustfollow.js b/lib/v2/pixiv/illustfollow.js index ee109babc6..608906024f 100644 --- a/lib/v2/pixiv/illustfollow.js +++ b/lib/v2/pixiv/illustfollow.js @@ -6,12 +6,12 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.refreshToken) { - throw 'pixiv RSS is disabled due to the lack of relevant config'; + throw new Error('pixiv RSS is disabled due to the lack of relevant config'); } const token = await getToken(ctx.cache.tryGet); if (!token) { - throw 'pixiv not login'; + throw new Error('pixiv not login'); } const response = await getIllustFollows(token); diff --git a/lib/v2/pixiv/ranking.js b/lib/v2/pixiv/ranking.js index eb1c163c35..c56178d5f7 100644 --- a/lib/v2/pixiv/ranking.js +++ b/lib/v2/pixiv/ranking.js @@ -57,7 +57,7 @@ const alias = { module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.refreshToken) { - throw 'pixiv RSS is disabled due to the lack of relevant config'; + throw new Error('pixiv RSS is disabled due to the lack of relevant config'); } const mode = alias[ctx.params.mode] ?? ctx.params.mode; @@ -65,7 +65,7 @@ module.exports = async (ctx) => { const token = await getToken(ctx.cache.tryGet); if (!token) { - throw 'pixiv not login'; + throw new Error('pixiv not login'); } const response = await getRanking(mode, ctx.params.date && date, token); diff --git a/lib/v2/pixiv/search.js b/lib/v2/pixiv/search.js index 56a1d6ad96..8c89dcc909 100644 --- a/lib/v2/pixiv/search.js +++ b/lib/v2/pixiv/search.js @@ -7,7 +7,7 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.refreshToken) { - throw 'pixiv RSS is disabled due to the lack of relevant config'; + throw new Error('pixiv RSS is disabled due to the lack of relevant config'); } const keyword = ctx.params.keyword; @@ -16,7 +16,7 @@ module.exports = async (ctx) => { const token = await getToken(ctx.cache.tryGet); if (!token) { - throw 'pixiv not login'; + throw new Error('pixiv not login'); } const response = await (order === 'popular' ? searchPopularIllust(keyword, token) : searchIllust(keyword, token)); diff --git a/lib/v2/pixiv/user.js b/lib/v2/pixiv/user.js index 1a6c853f3c..46c2d6eb5c 100644 --- a/lib/v2/pixiv/user.js +++ b/lib/v2/pixiv/user.js @@ -6,13 +6,13 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.refreshToken) { - throw 'pixiv RSS is disabled due to the lack of relevant config'; + throw new Error('pixiv RSS is disabled due to the lack of relevant config'); } const id = ctx.params.id; const token = await getToken(ctx.cache.tryGet); if (!token) { - throw 'pixiv not login'; + throw new Error('pixiv not login'); } const response = await getIllusts(id, token); diff --git a/lib/v2/sehuatang/user.js b/lib/v2/sehuatang/user.js index 27b54f6751..fbcfbdff1c 100644 --- a/lib/v2/sehuatang/user.js +++ b/lib/v2/sehuatang/user.js @@ -8,7 +8,7 @@ const baseUrl = 'https://sehuatang.org/'; module.exports = async (ctx) => { if (!config.sehuatang.cookie) { - throw 'Sehuatang RSS is disabled due to the lack of relevant config'; + throw new Error('Sehuatang RSS is disabled due to the lack of relevant config'); } // 从Url参数中获取uid const uid = ctx.params.uid; diff --git a/lib/v2/spotify/top.js b/lib/v2/spotify/top.js index db3f7ef631..084dc2f257 100644 --- a/lib/v2/spotify/top.js +++ b/lib/v2/spotify/top.js @@ -3,7 +3,7 @@ const got = require('@/utils/got'); module.exports = (type) => async (ctx) => { if (type !== 'tracks' && type !== 'artists') { - throw `Invalid type: ${type}`; + throw new Error(`Invalid type: ${type}`); } const token = await utils.getPrivateToken(); diff --git a/lib/v2/spotify/utils.js b/lib/v2/spotify/utils.js index 70f7184aa2..3492e87950 100644 --- a/lib/v2/spotify/utils.js +++ b/lib/v2/spotify/utils.js @@ -4,7 +4,7 @@ const got = require('@/utils/got'); // Token used to retrieve public information. async function getPublicToken() { if (!config.spotify || !config.spotify.clientId || !config.spotify.clientSecret) { - throw 'Spotify public RSS is disabled due to the lack of relevant config'; + throw new Error('Spotify public RSS is disabled due to the lack of relevant config'); } const { clientId, clientSecret } = config.spotify; @@ -26,7 +26,7 @@ async function getPublicToken() { // Note that we don't use PKCE since the client secret shall be safe on the server. async function getPrivateToken() { if (!config.spotify || !config.spotify.clientId || !config.spotify.clientSecret || !config.spotify.refreshToken) { - throw 'Spotify private RSS is disabled due to the lack of relevant config'; + throw new Error('Spotify private RSS is disabled due to the lack of relevant config'); } const { clientId, clientSecret, refreshToken } = config.spotify; diff --git a/lib/v2/sspai/author.js b/lib/v2/sspai/author.js index 95f4ee9dd7..75b137992c 100644 --- a/lib/v2/sspai/author.js +++ b/lib/v2/sspai/author.js @@ -11,7 +11,7 @@ async function getUserId(slug) { }); if (response.data.error !== 0) { - throw 'User Not Found'; + throw new Error('User Not Found'); } return response.data.data.id; diff --git a/lib/v2/telegram/channel.js b/lib/v2/telegram/channel.js index 3e21473f2d..ee3909a836 100644 --- a/lib/v2/telegram/channel.js +++ b/lib/v2/telegram/channel.js @@ -100,7 +100,7 @@ module.exports = async (ctx) => { : $('.tgme_widget_message_wrap:not(.tgme_widget_message_wrap:has(.service_message,.tme_no_messages_found))'); // also exclude service messages if (list.length === 0 && $('.tgme_channel_history').length === 0) { - throw `Unable to fetch message feed from this channel. Please check this URL to see if you can view the message preview: ${resourceUrl}`; + throw new Error(`Unable to fetch message feed from this channel. Please check this URL to see if you can view the message preview: ${resourceUrl}`); } const channelName = $('.tgme_channel_info_header_title').text(); diff --git a/lib/v2/telegram/stickerpack.js b/lib/v2/telegram/stickerpack.js index 2a64f170f6..42072b7ea8 100644 --- a/lib/v2/telegram/stickerpack.js +++ b/lib/v2/telegram/stickerpack.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.telegram || !config.telegram.token) { - throw 'Telegram Sticker Pack RSS is disabled due to the lack of relevant config'; + throw new Error('Telegram Sticker Pack RSS is disabled due to the lack of relevant config'); } const name = ctx.params.name; diff --git a/lib/v2/twitter/likes.js b/lib/v2/twitter/likes.js index 754b78eda3..e922461259 100644 --- a/lib/v2/twitter/likes.js +++ b/lib/v2/twitter/likes.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) { - throw 'Twitter RSS is disabled due to the lack of relevant config'; + throw new Error('Twitter RSS is disabled due to the lack of relevant config'); } const id = ctx.params.id; const client = await utils.getAppClient(); diff --git a/lib/v2/twitter/list.js b/lib/v2/twitter/list.js index dab5912ea5..928bb540d2 100644 --- a/lib/v2/twitter/list.js +++ b/lib/v2/twitter/list.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) { - throw 'Twitter RSS is disabled due to the lack of relevant config'; + throw new Error('Twitter RSS is disabled due to the lack of relevant config'); } const { id, name } = ctx.params; const client = await utils.getAppClient(); diff --git a/lib/v2/twitter/trends.js b/lib/v2/twitter/trends.js index 78a587606e..de7746a53e 100644 --- a/lib/v2/twitter/trends.js +++ b/lib/v2/twitter/trends.js @@ -3,7 +3,7 @@ const config = require('@/config').value; module.exports = async (ctx) => { if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) { - throw 'Twitter RSS is disabled due to the lack of relevant config'; + throw new Error('Twitter RSS is disabled due to the lack of relevant config'); } const woeid = ctx.params.woeid ?? 1; // Global information is available by using 1 as the WOEID const client = await utils.getAppClient(); diff --git a/lib/v2/ustc/eeis.js b/lib/v2/ustc/eeis.js index efc1afa7b8..c84288ef99 100644 --- a/lib/v2/ustc/eeis.js +++ b/lib/v2/ustc/eeis.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { const type = ctx.params.type ?? 'tzgg'; const info = map.get(type); if (!info) { - throw 'invalid type'; + throw new Error('invalid type'); } const id = info.id; diff --git a/lib/v2/ustc/gs.js b/lib/v2/ustc/gs.js index c66b45ddfa..d0b556c4fc 100644 --- a/lib/v2/ustc/gs.js +++ b/lib/v2/ustc/gs.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { const type = ctx.params.type ?? 'tzgg'; const info = map.get(type); if (!info) { - throw 'invalid type'; + throw new Error('invalid type'); } const id = info.id; diff --git a/lib/v2/ustc/sist.js b/lib/v2/ustc/sist.js index a6f3669bdb..d0b013300e 100644 --- a/lib/v2/ustc/sist.js +++ b/lib/v2/ustc/sist.js @@ -14,7 +14,7 @@ module.exports = async (ctx) => { const type = ctx.params.type ?? 'tzgg'; const info = map.get(type); if (!info) { - throw 'invalid type'; + throw new Error('invalid type'); } const id = info.id; diff --git a/lib/v2/weibo/friends.js b/lib/v2/weibo/friends.js index f49eff5785..03d5a57941 100644 --- a/lib/v2/weibo/friends.js +++ b/lib/v2/weibo/friends.js @@ -6,7 +6,7 @@ const { fallback, queryToBoolean } = require('@/utils/readable-social'); module.exports = async (ctx) => { if (!config.weibo.cookies) { - throw 'Weibo Friends Timeline is not available due to the absense of [Weibo Cookies]. Check relevant config tutorial'; + throw new Error('Weibo Friends Timeline is not available due to the absense of [Weibo Cookies]. Check relevant config tutorial'); } let displayVideo = '1'; diff --git a/lib/v2/weibo/group.js b/lib/v2/weibo/group.js index 1389b197e8..3a8e069070 100644 --- a/lib/v2/weibo/group.js +++ b/lib/v2/weibo/group.js @@ -6,7 +6,7 @@ const { fallback, queryToBoolean } = require('@/utils/readable-social'); module.exports = async (ctx) => { if (!config.weibo.cookies) { - throw 'Weibo Group Timeline is not available due to the absense of [Weibo Cookies]. Check relevant config tutorial'; + throw new Error('Weibo Group Timeline is not available due to the absense of [Weibo Cookies]. Check relevant config tutorial'); } const gid = ctx.params.gid; diff --git a/lib/v2/youtube/custom.js b/lib/v2/youtube/custom.js index 373f87cadc..7e2695144f 100644 --- a/lib/v2/youtube/custom.js +++ b/lib/v2/youtube/custom.js @@ -6,7 +6,7 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { if (!config.youtube || !config.youtube.key) { - throw 'YouTube RSS is disabled due to the lack of relevant config'; + throw new Error('YouTube RSS is disabled due to the lack of relevant config'); } const { username } = ctx.params; const embed = !ctx.params.embed; diff --git a/lib/v2/youtube/playlist.js b/lib/v2/youtube/playlist.js index 06afb05c48..c79fdf1166 100644 --- a/lib/v2/youtube/playlist.js +++ b/lib/v2/youtube/playlist.js @@ -4,7 +4,7 @@ const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { if (!config.youtube || !config.youtube.key) { - throw 'YouTube RSS is disabled due to the lack of relevant config'; + throw new Error('YouTube RSS is disabled due to the lack of relevant config'); } const id = ctx.params.id; const embed = !ctx.params.embed; diff --git a/lib/v2/youtube/subscriptions.js b/lib/v2/youtube/subscriptions.js index 4f6b74b59e..9298d90278 100644 --- a/lib/v2/youtube/subscriptions.js +++ b/lib/v2/youtube/subscriptions.js @@ -5,7 +5,7 @@ const asyncPool = require('tiny-async-pool'); module.exports = async (ctx) => { if (!config.youtube || !config.youtube.key || !config.youtube.clientId || !config.youtube.clientSecret || !config.youtube.refreshToken) { - throw 'YouTube RSS is disabled due to the lack of relevant config'; + throw new Error('YouTube RSS is disabled due to the lack of relevant config'); } const embed = !ctx.params.embed;