From 4389fe55f30d59e4b12c46f256543eb37a4b8454 Mon Sep 17 00:00:00 2001 From: duncdrum Date: Wed, 27 Apr 2022 00:08:24 +0200 Subject: [PATCH] fix(xqSuite.js): make XQTS error more robust --- generators/app/templates/specs/xqs/xqSuite.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generators/app/templates/specs/xqs/xqSuite.js b/generators/app/templates/specs/xqs/xqSuite.js index fa06dbac9..21fad1cf2 100644 --- a/generators/app/templates/specs/xqs/xqSuite.js +++ b/generators/app/templates/specs/xqs/xqSuite.js @@ -27,7 +27,7 @@ http.get(url, (res) => { // NOTE(DP): XQTS errors on testsuite, will be returned as application/xml // The initial check will display the XQTS error, and run the test suite otherwise // see #800 - if (res.ContentType == "application/json") { + if (res.headers['content-type'].includes("application/json")) { let xqsReport = JSON.parse(data) let xqsPkg = xqsReport.testsuite.package let xqstCount = xqsReport.testsuite.tests @@ -55,8 +55,9 @@ http.get(url, (res) => { }) } else { - let doc = new xmldoc.XmlDocument(data) - throw new Error(doc.childNamed("message").val) + try { let doc = new xmldoc.XmlDocument(data) + throw new Error(doc.childNamed("message").val) } + catch (e) { console.log(e.message) } } }) }).on('error', (err) => {