@naturalcycles/backend-lib 5.6.1 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,7 +16,7 @@ export interface GenericErrorMiddlewareCfg {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Generic error handler.
|
|
19
|
-
* Returns HTTP code based on err.data.
|
|
19
|
+
* Returns HTTP code based on err.data.backendResponseStatusCode (default to 500).
|
|
20
20
|
* Sends json payload as ErrorResponse, transformed via errorSharedUtil.
|
|
21
21
|
*/
|
|
22
22
|
export declare function genericErrorMiddleware(cfg?: GenericErrorMiddlewareCfg): BackendErrorRequestHandler;
|
|
@@ -11,7 +11,7 @@ let reportOnly5xx = false;
|
|
|
11
11
|
let formatError;
|
|
12
12
|
/**
|
|
13
13
|
* Generic error handler.
|
|
14
|
-
* Returns HTTP code based on err.data.
|
|
14
|
+
* Returns HTTP code based on err.data.backendResponseStatusCode (default to 500).
|
|
15
15
|
* Sends json payload as ErrorResponse, transformed via errorSharedUtil.
|
|
16
16
|
*/
|
|
17
17
|
function genericErrorMiddleware(cfg = {}) {
|
|
@@ -53,9 +53,6 @@ function respondWithError(req, res, err) {
|
|
|
53
53
|
delete httpError.stack;
|
|
54
54
|
httpError.data.errorId = errorId;
|
|
55
55
|
httpError.data.backendResponseStatusCode ||= 500; // default to 500
|
|
56
|
-
// httpStatusCode is for backwards-compatibility
|
|
57
|
-
// Otherwise, it breaks the _isHttpErrorResponse function check, and error get formatted/detected wrongly
|
|
58
|
-
httpError.data['httpStatusCode'] = httpError.data.backendResponseStatusCode;
|
|
59
56
|
httpError.data.headersSent = headersSent || undefined;
|
|
60
57
|
(0, js_lib_1._filterUndefinedValues)(httpError.data, true);
|
|
61
58
|
formatError?.(httpError); // Mutates
|
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@ let formatError: GenericErrorMiddlewareCfg['formatError']
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Generic error handler.
|
|
38
|
-
* Returns HTTP code based on err.data.
|
|
38
|
+
* Returns HTTP code based on err.data.backendResponseStatusCode (default to 500).
|
|
39
39
|
* Sends json payload as ErrorResponse, transformed via errorSharedUtil.
|
|
40
40
|
*/
|
|
41
41
|
export function genericErrorMiddleware(
|
|
@@ -86,9 +86,6 @@ export function respondWithError(req: BackendRequest, res: BackendResponse, err:
|
|
|
86
86
|
|
|
87
87
|
httpError.data.errorId = errorId
|
|
88
88
|
httpError.data.backendResponseStatusCode ||= 500 // default to 500
|
|
89
|
-
// httpStatusCode is for backwards-compatibility
|
|
90
|
-
// Otherwise, it breaks the _isHttpErrorResponse function check, and error get formatted/detected wrongly
|
|
91
|
-
httpError.data['httpStatusCode'] = httpError.data.backendResponseStatusCode
|
|
92
89
|
httpError.data.headersSent = headersSent || undefined
|
|
93
90
|
_filterUndefinedValues(httpError.data, true)
|
|
94
91
|
|