parent
f58a715c45
commit
1fb09e577c
@ -1,20 +1,14 @@
|
|||||||
import {
|
import { ExpressErrorMiddlewareInterface, Middleware } from "routing-controllers";
|
||||||
Middleware,
|
|
||||||
ExpressErrorMiddlewareInterface
|
|
||||||
} from "routing-controllers";
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our Error handling middlware that returns our custom httperrors to the user
|
||||||
|
*/
|
||||||
@Middleware({ type: "after" })
|
@Middleware({ type: "after" })
|
||||||
export class ErrorHandler implements ExpressErrorMiddlewareInterface {
|
export class ErrorHandler implements ExpressErrorMiddlewareInterface {
|
||||||
public error(
|
public error(error: any, request: any, response: any, next: (err: any) => any) {
|
||||||
error: any,
|
|
||||||
request: any,
|
|
||||||
response: any,
|
|
||||||
next: (err: any) => any
|
|
||||||
) {
|
|
||||||
if (response.headersSent) {
|
if (response.headersSent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
response.json(error);
|
response.json(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user