aboutsummaryrefslogtreecommitdiff
path: root/src/errors
diff options
context:
space:
mode:
authorTom Harley2018-04-21 03:07:02 +0100
committerTom Harley2018-04-21 03:07:02 +0100
commit4237e378c70c0d6adb3dab4c9ba5cf5385f4a6ec (patch)
tree59c487fc0019040448a9713b3c4c146a560ec13d /src/errors
parentMerge branch 'trh/gets' of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/projec... (diff)
parentFix many small file-handling problems (diff)
downloadmedicine-4237e378c70c0d6adb3dab4c9ba5cf5385f4a6ec.tar.gz
medicine-4237e378c70c0d6adb3dab4c9ba5cf5385f4a6ec.zip

Merge branch ‘trh/files’ into trh/gets

Diffstat (limited to 'src/errors')
-rw-r--r--src/errors/errorware.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/errors/errorware.ts b/src/errors/errorware.ts
index 6d87bcb..e2b5610 100644
--- a/src/errors/errorware.ts
+++ b/src/errors/errorware.ts
@@ -1,5 +1,7 @@
import { NextFunction, Request, Response } from 'express';
+import { logger } from '../logger';
+
/**
* General error and error-handling logic for the middleware stack.
*/
@@ -115,10 +117,11 @@ export type Errorware =
export const errorHandler: Errorware = (
err: Error, req: Request, res: Response, next: NextFunction
): void => {
+ logger.failure(`Responded to ${req.ip}`);
if (RequestError.is(err)) {
res.status(err.code)
.json(err.responseBlock());
} else {
- res.send(err);
+ res.status(500).send(err.stack);
}
};