backend-manager 3.1.3 → 3.1.4
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.
package/package.json
CHANGED
|
@@ -371,7 +371,9 @@ BackendAssistant.prototype.errorify = function (e, options) {
|
|
|
371
371
|
? e
|
|
372
372
|
: new Error(stringify(e));
|
|
373
373
|
|
|
374
|
+
// Fix code
|
|
374
375
|
options.code = newError.code || options.code;
|
|
376
|
+
options.code = isBetween(options.code, 400, 599) ? options.code : 500;
|
|
375
377
|
|
|
376
378
|
// Attach properties
|
|
377
379
|
_attachHeaderProperties(self, options, newError);
|
|
@@ -428,10 +430,12 @@ BackendAssistant.prototype.respond = function(response, options) {
|
|
|
428
430
|
: options.log;
|
|
429
431
|
|
|
430
432
|
// Handle error
|
|
433
|
+
const isErrorCode = isBetween(options.code, 400, 599);
|
|
431
434
|
if (
|
|
432
435
|
response instanceof Error
|
|
433
|
-
||
|
|
436
|
+
|| isErrorCode
|
|
434
437
|
) {
|
|
438
|
+
options.code = !isErrorCode ? undefined : options.code;
|
|
435
439
|
return self.errorify(response, options);
|
|
436
440
|
}
|
|
437
441
|
|
|
@@ -454,6 +458,10 @@ BackendAssistant.prototype.respond = function(response, options) {
|
|
|
454
458
|
}
|
|
455
459
|
}
|
|
456
460
|
|
|
461
|
+
function isBetween(value, min, max) {
|
|
462
|
+
return value >= min && value <= max;
|
|
463
|
+
}
|
|
464
|
+
|
|
457
465
|
function stringify(e) {
|
|
458
466
|
if (typeof e === 'string') {
|
|
459
467
|
return e;
|