Added errorhandler middleware
This commit is contained in:
parent
9d62225478
commit
6539fd7855
|
@ -0,0 +1,14 @@
|
|||
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) {
|
||||
if (response.headersSent) {
|
||||
return;
|
||||
}
|
||||
response.json(error);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue