diff --git a/lib/errors/index.test.ts b/lib/errors/index.test.ts
index dc58186aa..e1af51058 100644
--- a/lib/errors/index.test.ts
+++ b/lib/errors/index.test.ts
@@ -35,6 +35,22 @@ describe('RequestInProgressError', () => {
});
});
+describe('config-not-found-error', () => {
+ it(`config-not-found-error`, async () => {
+ const response = await request.get('/test/config-not-found-error');
+ expect(response.status).toBe(503);
+ expect(response.text).toMatch('ConfigNotFoundError: Test config not found error');
+ }, 20000);
+});
+
+describe('invalid-parameter-error', () => {
+ it(`invalid-parameter-error`, async () => {
+ const response = await request.get('/test/invalid-parameter-error');
+ expect(response.status).toBe(503);
+ expect(response.text).toMatch('InvalidParameterError: Test invalid parameter error');
+ }, 20000);
+});
+
describe('route throws an error', () => {
it('route path error should have path mounted', async () => {
await request.get('/test/error');
@@ -47,19 +63,19 @@ describe('route throws an error', () => {
const value = $(item).find('.debug-value').html()?.trim();
switch (key) {
case 'Request Amount:':
- expect(value).toBe('7');
+ expect(value).toBe('9');
break;
case 'Hot Routes:':
- expect(value).toBe('4 /test/:id
');
+ expect(value).toBe('6 /test/:id
');
break;
case 'Hot Paths:':
- expect(value).toBe('2 /test/error
2 /test/slow
1 /test/httperror
1 /thisDoesNotExist
1 /
');
+ expect(value).toBe('2 /test/error
2 /test/slow
1 /test/httperror
1 /test/config-not-found-error
1 /test/invalid-parameter-error
1 /thisDoesNotExist
1 /
');
break;
case 'Hot Error Routes:':
- expect(value).toBe('3 /test/:id
');
+ expect(value).toBe('5 /test/:id
');
break;
case 'Hot Error Paths:':
- expect(value).toBe('2 /test/error
1 /test/httperror
1 /test/slow
1 /thisDoesNotExist
');
+ expect(value).toBe('2 /test/error
1 /test/httperror
1 /test/slow
1 /test/config-not-found-error
1 /test/invalid-parameter-error
1 /thisDoesNotExist
');
break;
default:
}
diff --git a/lib/routes/test/index.ts b/lib/routes/test/index.ts
index 752fad595..138e3691b 100644
--- a/lib/routes/test/index.ts
+++ b/lib/routes/test/index.ts
@@ -3,6 +3,8 @@ import { config } from '@/config';
import got from '@/utils/got';
import wait from '@/utils/wait';
import cache from '@/utils/cache';
+import ConfigNotFoundError from '@/errors/types/config-not-found';
+import InvalidParameterError from '@/errors/types/invalid-parameter';
let cacheIndex = 0;
@@ -23,6 +25,12 @@ async function handler(ctx) {
url: 'https://httpbingo.org/status/404',
});
}
+ if (ctx.req.param('id') === 'config-not-found-error') {
+ throw new ConfigNotFoundError('Test config not found error');
+ }
+ if (ctx.req.param('id') === 'invalid-parameter-error') {
+ throw new InvalidParameterError('Test invalid parameter error');
+ }
let item: DataItem[] = [];
switch (ctx.req.param('id')) {
case 'filter':