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:
parent
516122e058
commit
a174ec76c1
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -9,7 +9,8 @@ export enum ErrorCodes{
|
||||
USER_CREATION_ERROR,
|
||||
|
||||
|
||||
GENERAL_ERROR
|
||||
GENERAL_ERROR,
|
||||
SERVER_ERROR
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user