Permalink
Browse files

Added a try/catch around jsdom/jquery initialization for pages

  • Loading branch information...
1 parent ea1b22f commit dbdecf127289022782b98562445675e3c024ad21 @jhurliman jhurliman committed Jul 26, 2011
Showing with 11 additions and 5 deletions.
  1. +11 −5 lib/node.io/dom.js
View
@@ -50,12 +50,18 @@ Job.prototype.parseHtml = function (data, callback, response) {
ProcessExternalResources: this.options.external_resources,
QuerySelector: false
};
- var $, window = require('jsdom').jsdom(data, null, {features:features}).createWindow(),
- jquery = require('jquery')
+ var $, window, jquery, default_$;
+ try {
+ window = require('jsdom').jsdom(data, null, {features:features}).createWindow();
+ jquery = require('jquery');
default_$ = jquery.create(window);
- $ = function (selector, context) {
- return context ? jquery.create(context)(selector) : default_$(selector);
- };
+ $ = function (selector, context) {
+ return context ? jquery.create(context)(selector) : default_$(selector);
+ };
+ } catch (e) {
+ callback.apply(self, [e, $, data, headers, response]);
+ return;
+ }
if (recurse === 1 || recurse === true || recurse instanceof Array) {
this.recurseUrls($);
}

0 comments on commit dbdecf1

Please sign in to comment.