From ac40cb4e8aa556c010a41d50d118459c278866d8 Mon Sep 17 00:00:00 2001 From: Ratchanan Srirattanamet Date: Thu, 13 Sep 2018 01:26:44 +0700 Subject: [PATCH] WSDL: pass error from parsing XML as-is, not only its message 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 af1574ad2..f744d5a5d 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);