1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-12-05 23:18:43 +02:00

improving error handling

This commit is contained in:
Braun Patrik
2016-05-06 10:48:51 +02:00
parent 516122e058
commit a174ec76c1
3 changed files with 7 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
///<reference path="../../typings/main.d.ts"/>
import {RenderingMWs} from "../middlewares/RenderingMWs";
import {Error, ErrorCodes} from "../../common/entities/Error";
export class ErrorRouter{
constructor(private app) {
@@ -17,15 +18,13 @@ export class ErrorRouter{
private addGenericHandler() {
this.app.use((err, req, res, next) => {
res.status(500).send('Houston, we have a problem!');
//Flush out the stack to the console
console.error(err.stack);
});
next(new Error(ErrorCodes.SERVER_ERROR,"Unknown server side error"));
},
RenderingMWs.renderError
);
}
}