From c86cd7e7a83ae111ba3b1bd0442c76bdf846ec2c Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Thu, 20 Feb 2020 10:33:16 +1100 Subject: [PATCH] Add a try/catch in NPM/Zombie.js driver --- src/apps.json | 2 +- src/drivers/npm/browsers/zombie.js | 40 ++++++++++++++++-------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/apps.json b/src/apps.json index 9f3d156a1..1b732e9fc 100644 --- a/src/apps.json +++ b/src/apps.json @@ -9794,7 +9794,7 @@ ], "icon": "Sencha Touch.png", "script": "sencha-touch.*\\.js", - "website": "http://sencha.com/products/touch" + "website": "http://www.sencha.com/products/touch" }, "Seravo": { "cats": [ diff --git a/src/drivers/npm/browsers/zombie.js b/src/drivers/npm/browsers/zombie.js index 28f6ba3ce..170ae2236 100644 --- a/src/drivers/npm/browsers/zombie.js +++ b/src/drivers/npm/browsers/zombie.js @@ -20,24 +20,28 @@ class ZombieBrowser extends Browser { } visit(url) { - return new Promise((resolve) => { - this.browser.visit(url, () => { - const resource = this.browser.resources.length - ? this.browser.resources.filter(_resource => _resource.response).shift() : null; - - this.window = this.browser.window; - this.document = this.browser.document; - this.headers = this.getHeaders(); - this.statusCode = resource ? resource.response.status : 0; - this.contentType = this.headers['content-type'] ? this.headers['content-type'].shift() : null; - this.html = this.getHtml(); - this.js = this.getJs(); - this.links = this.getLinks(); - this.scripts = this.getScripts(); - this.cookies = this.getCookies(); - - resolve(); - }); + return new Promise((resolve, reject) => { + try { + this.browser.visit(url, () => { + const resource = this.browser.resources.length + ? this.browser.resources.filter(_resource => _resource.response).shift() : null; + + this.window = this.browser.window; + this.document = this.browser.document; + this.headers = this.getHeaders(); + this.statusCode = resource ? resource.response.status : 0; + this.contentType = this.headers['content-type'] ? this.headers['content-type'].shift() : null; + this.html = this.getHtml(); + this.js = this.getJs(); + this.links = this.getLinks(); + this.scripts = this.getScripts(); + this.cookies = this.getCookies(); + + resolve(); + }); + } catch (error) { + reject(error.message); + } }); }