Comparing version 1.3.1 to 1.4.0
{ | ||
"name": "nodegate", | ||
"description": "API gateway made simple, fast and easy to configure.", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"author": "Julien Martin <martin.julien82@gmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -30,2 +30,3 @@ /** | ||
const buildedUrl = urlBuilder(url); | ||
const failStatusCodes = options.failStatusCodes || [400, 500]; | ||
return async (container) => { | ||
@@ -42,8 +43,18 @@ try { | ||
} catch (err) { | ||
const body = err.response && err.response.body; | ||
const statusCode = err.response ? err.response.statusCode : 500; | ||
if (body && !failStatusCodes.includes(parseInt(`${`${statusCode}[0]`}00`, 10))) { | ||
setBodyToContainer(body, container, options); | ||
container.statusCode = statusCode; | ||
return; | ||
} | ||
const error = new WorkflowError(err, err.response); | ||
error.setContainer(container); | ||
if (err.response && err.response.body) { | ||
container.errorBody = err.response.body; | ||
if (body) { | ||
container.errorBody = body; | ||
} | ||
container.statusCode = err.response ? err.response.statusCode : 500; | ||
container.statusCode = statusCode; | ||
throw error; | ||
@@ -50,0 +61,0 @@ } |
21645
547