Skip to content

Commit

Permalink
WSDL: pass error from parsing XML as-is, not only its message (#1022)
Browse files Browse the repository at this point in the history
By passing only error's message, callee losses information about stack,
which is helpful in debugging. Besides, passing string as error breaks
mocha. (See mochajs/mocha#3320)
  • Loading branch information
peat-psuwit authored and jsdevel committed Feb 11, 2019
1 parent 6bb6936 commit 0e8a3e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/wsdl.js
Expand Up @@ -1047,7 +1047,7 @@ var WSDL = function(definition, uri, options) {
try {
fromFunc.call(self, definition);
} catch (e) {
return self.callback(e.message);
return self.callback(e);
}

self.processIncludes(function(err) {
Expand Down
14 changes: 14 additions & 0 deletions test/wsdl-test.js
Expand Up @@ -51,6 +51,20 @@ wsdlStrictTests['should catch parse error'] = function(done) {
});
};

wsdlNonStrictTests['should not give error as string'] = function(done) {
soap.createClient(__dirname+'/wsdl/bad.txt', function(err) {
assert.notEqual(typeof err, 'string');
done();
});
};

wsdlStrictTests['should not give error as string'] = function(done) {
soap.createClient(__dirname+'/wsdl/bad.txt', function(err) {
assert.notEqual(typeof err, 'string');
done();
});
};

wsdlStrictTests['should parse external wsdl'] = function(done) {
soap.createClient(__dirname+'/wsdl/wsdlImport/main.wsdl', {strict: true}, function(err, client){
assert.ifError(err);
Expand Down

0 comments on commit 0e8a3e6

Please sign in to comment.