test: errors
This commit is contained in:
parent
f7048d4c24
commit
f5ced001eb
|
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue