File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
// eslint-disable-next-line no-unused-vars
2
2
import { NextFunction , Request , Response } from 'express'
3
- import ResponseError from 'modules/ResponseError'
3
+ import ResponseError from 'modules/Response/ ResponseError'
4
4
import { isObject } from 'lodash'
5
5
6
- function generateErrorResponseError ( e : Error ) {
7
- return isObject ( e . message ) ? e . message : { message : e . message }
6
+ function generateErrorResponseError ( e : Error , code : Number ) {
7
+ return isObject ( e . message ) ? e . message : { code , message : e . message }
8
8
}
9
9
10
10
async function ExpressErrorResponse (
@@ -14,7 +14,9 @@ async function ExpressErrorResponse(
14
14
next : NextFunction
15
15
) {
16
16
if ( err instanceof ResponseError . BaseResponse ) {
17
- return res . status ( err . statusCode ) . json ( generateErrorResponseError ( err ) )
17
+ return res
18
+ . status ( err . statusCode )
19
+ . json ( generateErrorResponseError ( err , err . statusCode ) )
18
20
}
19
21
20
22
next ( err )
You can’t perform that action at this time.
0 commit comments