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