test: errors

This commit is contained in:
DIYgod 2024-03-31 03:17:53 +08:00
parent f7048d4c24
commit f5ced001eb
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View File

@ -22,7 +22,7 @@ describe('httperror', () => {
it(`httperror`, async () => {
const response = await request.get('/test/httperror');
expect(response.status).toBe(503);
expect(response.text).toMatch('Response code 404 (Not Found): target website might be blocking our access, you can host your own RSSHub instance for a better usability.');
expect(response.text).toMatch('404 Not Found: target website might be blocking our access, you can host your own RSSHub instance for a better usability.');
}, 20000);
});

View File

@ -39,7 +39,7 @@ export const errorHandler: ErrorHandler = (error, ctx) => {
}
let message = '';
if (error.name && (error.name === 'HTTPError' || error.name === 'RequestError')) {
if (error.name && (error.name === 'HTTPError' || error.name === 'RequestError' || error.name === 'FetchError')) {
ctx.status(503);
message = `${error.message}: target website might be blocking our access, you can host your own RSSHub instance for a better usability.`;
} else if (error instanceof RequestInProgressError) {