1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08: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
);
}
}

View File

@ -9,7 +9,8 @@ export enum ErrorCodes{
USER_CREATION_ERROR,
GENERAL_ERROR
GENERAL_ERROR,
SERVER_ERROR
}

View File

@ -9,8 +9,6 @@ import {Directory} from "../../../common/entities/Directory";
@Injectable()
export class GalleryService{
constructor(private _networkService:NetworkService){
}
@ -18,8 +16,4 @@ export class GalleryService{
return this._networkService.getJson("/gallery/content/"+directoryName);
}
}