From 0e8a3e6b5279bc46f8f6af2cb6b8561b4997f64b Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Tue, 12 Feb 2019 01:21:21 +0700 Subject: [PATCH] WSDL: pass error from parsing XML as-is, not only its message (#1022) By passing only error's message, callee losses information about stack, which is helpful in debugging. Besides, passing string as error breaks mocha. (See https://github.com/mochajs/mocha/issues/3320) --- lib/wsdl.js | 2 +- test/wsdl-test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/wsdl.js b/lib/wsdl.js index 65abe8dc4..8edf54bf7 100644 --- a/lib/wsdl.js +++ b/lib/wsdl.js @@ -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) { diff --git a/test/wsdl-test.js b/test/wsdl-test.js index a4e949353..61d68db6e 100644 --- a/test/wsdl-test.js +++ b/test/wsdl-test.js @@ -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);