fix(route): throw better errors (#14461)

This commit is contained in:
Tony
2024-02-15 07:53:01 +08:00
committed by GitHub
parent 9d0ad266d2
commit 5058906b85
59 changed files with 69 additions and 69 deletions
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Disqus RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const forum = ctx.params.forum;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Fanfou RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const uid = ctx.params.uid;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Fanfou RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const fanfou = await utils.getFanfou();
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Fanfou RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const keyword = ctx.params.keyword;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Fanfou RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const uid = ctx.params.uid;
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Last.fm RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const user = ctx.params.user;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Last.fm RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const user = ctx.params.user;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Last.fm RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const country = ctx.params.country;
+1 -1
View File
@@ -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`
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('163 Music RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const id = ctx.params.id;
+1 -1
View File
@@ -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;
+3 -3
View File
@@ -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`;
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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) =>
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Ehentai favorites RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const favcat = ctx.params.favcat ? Number.parseInt(ctx.params.favcat) : 0;
const page = ctx.params.page;
+2 -2
View File
@@ -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;
}
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('GitHub follower RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const user = ctx.params.user;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('GitHub star RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const user = ctx.params.user;
const repo = ctx.params.repo;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('GitHub star RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const user = ctx.params.user;
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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) => ({
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('manhuagui RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const cookie = config.manhuagui.cookie;
const response = await got({
+1 -1
View File
@@ -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;
});
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>';
throw new Error('GetUserFullInfo is not available due to the absense of [Miyoushe Cookie]. Check <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>');
}
uid ||= '';
const key = 'mihoyo:user-full-info-uid-' + uid;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>';
throw new Error('Miyoushe Timeline is not available due to the absense of [Miyoushe Cookie]. Check <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>');
}
const page_size = ctx.query.limit || '20';
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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(<a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>)';
throw new Error('Notion RSS is disabled due to the lack of NOTION_TOKEN(<a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>)');
}
const databaseId = ctx.params.databaseId;
+1 -1
View File
@@ -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 = [];
+2 -2
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('pianyuan is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
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;
}
+2 -2
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
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)]);
+2 -2
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const token = await getToken(ctx.cache.tryGet);
if (!token) {
throw 'pixiv not login';
throw new Error('pixiv not login');
}
const response = await getIllustFollows(token);
+2 -2
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
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);
+2 -2
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
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));
+2 -2
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
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);
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Sehuatang RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
// 从Url参数中获取uid
const uid = ctx.params.uid;
+1 -1
View File
@@ -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();
+2 -2
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Spotify public RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Spotify private RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const { clientId, clientSecret, refreshToken } = config.spotify;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Telegram Sticker Pack RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const name = ctx.params.name;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Twitter RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const id = ctx.params.id;
const client = await utils.getAppClient();
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Twitter RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const { id, name } = ctx.params;
const client = await utils.getAppClient();
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('Twitter RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const woeid = ctx.params.woeid ?? 1; // Global information is available by using 1 as the WOEID
const client = await utils.getAppClient();
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>';
throw new Error('Weibo Friends Timeline is not available due to the absense of [Weibo Cookies]. Check <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>');
}
let displayVideo = '1';
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>';
throw new Error('Weibo Group Timeline is not available due to the absense of [Weibo Cookies]. Check <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config tutorial</a>');
}
const gid = ctx.params.gid;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('YouTube RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const { username } = ctx.params;
const embed = !ctx.params.embed;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('YouTube RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const id = ctx.params.id;
const embed = !ctx.params.embed;
+1 -1
View File
@@ -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 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
throw new Error('YouTube RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
}
const embed = !ctx.params.embed;