Skip to content

Commit

Permalink
Merge pull request #141 from bl0ggy/better_soap_error_handling
Browse files Browse the repository at this point in the history
Better SOAP error handling
  • Loading branch information
RogerHardiman authored Feb 20, 2020
2 parents e6ace4b + e57d9b2 commit 1a99557
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,25 @@ const parseSOAPString = function(xml, callback) {
if (!err && result['envelope']['body'][0]['fault']) {
var fault = result['envelope']['body'][0]['fault'][0];
var reason;
if (fault['reason'][0]['text'][0]._) {
reason = fault['reason'][0]['text'][0]._;
try {
if (fault.reason[0].text[0]._) {
reason = fault.reason[0].text[0]._;
}
} catch (e) {
reason = '';
}
if (!reason) {
reason = JSON.stringify(linerase(result.envelope.body[0].fault[0].code[0]));
try {
reason = JSON.stringify(linerase(fault.code[0]));
} catch (e) {
reason = '';
}
}
var detail = '';
if (result.envelope.body[0].fault[0].detail && result.envelope.body[0].fault[0].detail[0].text[0]) {
detail = result.envelope.body[0].fault[0].detail[0].text[0];
try {
detail = fault.detail[0].text[0];
} catch (e) {
detail = '';
}

// console.error('Fault:', reason, detail);
Expand Down

0 comments on commit 1a99557

Please sign in to comment.