It's InputError then

This commit is contained in:
Fredrik Adelöw
2020-05-04 16:42:40 +02:00
parent 129991fcfd
commit 9724084186
3 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -48,9 +48,9 @@ class CustomErrorBase extends Error {
}
/**
* The request is malformed and cannot be processed.
* The given inputs are malformed and cannot be processed.
*/
export class BadRequestError extends CustomErrorBase {}
export class InputError extends CustomErrorBase {}
/**
* The request requires authentication, which was not properly supplied.
@@ -49,8 +49,8 @@ describe('errorHandler', () => {
it('handles well-known error classes', async () => {
const app = express();
app.use('/BadRequestError', () => {
throw new errors.BadRequestError();
app.use('/InputError', () => {
throw new errors.InputError();
});
app.use('/AuthenticationError', () => {
throw new errors.AuthenticationError();
@@ -67,7 +67,7 @@ describe('errorHandler', () => {
app.use(errorHandler());
const r = request(app);
expect((await r.get('/BadRequestError')).status).toBe(400);
expect((await r.get('/InputError')).status).toBe(400);
expect((await r.get('/AuthenticationError')).status).toBe(401);
expect((await r.get('/NotAllowedError')).status).toBe(403);
expect((await r.get('/NotFoundError')).status).toBe(404);
@@ -79,7 +79,7 @@ function getStatusCode(error: Error): number {
// Handle well-known error types
switch (error.name) {
case errors.BadRequestError.name:
case errors.InputError.name:
return 400;
case errors.AuthenticationError.name:
return 401;