1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-14 11:23:17 +02:00
pigallery2/backend/routes/ErrorRouter.ts

31 lines
632 B
TypeScript
Raw Normal View History

///<reference path="../../typings/main.d.ts"/>
import {RenderingMWs} from "../middlewares/RenderingMWs";
export class ErrorRouter{
constructor(private app) {
this.addApiErrorHandler();
2016-04-22 13:23:44 +02:00
this.addGenericHandler();
}
private addApiErrorHandler() {
this.app.use("/api/*",
RenderingMWs.renderError
);
};
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);
});
}
}