Add a try/catch in NPM/Zombie.js driver

main
Elbert Alias 5 years ago
parent 62f881127c
commit c86cd7e7a8

@ -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": [

@ -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);
}
});
}

Loading…
Cancel
Save