You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2026-05-16 09:21:12 +02:00
improving error handling
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
///<reference path="../../typings/main.d.ts"/>
|
///<reference path="../../typings/main.d.ts"/>
|
||||||
|
|
||||||
import {RenderingMWs} from "../middlewares/RenderingMWs";
|
import {RenderingMWs} from "../middlewares/RenderingMWs";
|
||||||
|
import {Error, ErrorCodes} from "../../common/entities/Error";
|
||||||
|
|
||||||
export class ErrorRouter{
|
export class ErrorRouter{
|
||||||
constructor(private app) {
|
constructor(private app) {
|
||||||
@@ -17,15 +18,13 @@ export class ErrorRouter{
|
|||||||
|
|
||||||
private addGenericHandler() {
|
private addGenericHandler() {
|
||||||
this.app.use((err, req, res, next) => {
|
this.app.use((err, req, res, next) => {
|
||||||
res.status(500).send('Houston, we have a problem!');
|
|
||||||
|
|
||||||
//Flush out the stack to the console
|
//Flush out the stack to the console
|
||||||
console.error(err.stack);
|
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,
|
USER_CREATION_ERROR,
|
||||||
|
|
||||||
|
|
||||||
GENERAL_ERROR
|
GENERAL_ERROR,
|
||||||
|
SERVER_ERROR
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import {Directory} from "../../../common/entities/Directory";
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class GalleryService{
|
export class GalleryService{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(private _networkService:NetworkService){
|
constructor(private _networkService:NetworkService){
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,8 +16,4 @@ export class GalleryService{
|
|||||||
return this._networkService.getJson("/gallery/content/"+directoryName);
|
return this._networkService.getJson("/gallery/content/"+directoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user