@itentialopensource/adapter-utils
Advanced tools
Comparing version 4.30.6 to 4.30.7
## 4.30.7 [02-13-2020] | ||
* add in a response that can be parsed | ||
Closes ADAPT-89 | ||
See merge request itentialopensource/adapter-utils!162 | ||
--- | ||
## 4.30.6 [02-10-2020] | ||
@@ -3,0 +13,0 @@ |
@@ -138,3 +138,8 @@ /* @copyright Itential, LLC 2018 */ | ||
try { | ||
return callback(null, parser.toJson(retErrorObj, { object: true })); | ||
// if we have a response, try to parse it to JSON | ||
if (perror.response) { | ||
retError = parser.toJson(perror.response, { object: true }); | ||
retErrorObj.response = retError; | ||
} | ||
return callback(null, retErrorObj); | ||
} catch (ex) { | ||
@@ -147,9 +152,9 @@ log.warn(`${origin}: Unable to parse json ${ex}`); | ||
// process the error response - parse it if possible | ||
if (perror.raw_response) { | ||
if (perror.response) { | ||
if (entitySchema && entitySchema.responseDatatype && entitySchema.responseDatatype.toUpperCase() === 'URLENCODE') { | ||
// return the response | ||
retError = querystring.parse(perror.raw_response.trim()); | ||
retError = querystring.parse(perror.response.trim()); | ||
} else { | ||
try { | ||
retError = JSON.parse(perror.raw_response.trim()); | ||
retError = JSON.parse(perror.response.trim()); | ||
} catch (ex) { | ||
@@ -156,0 +161,0 @@ // otherwise log parse failure but still return the unparsed error |
{ | ||
"name": "@itentialopensource/adapter-utils", | ||
"version": "4.30.6", | ||
"version": "4.30.7", | ||
"description": "Itential Adapter Utility Libraries", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1615962
14050