Permalink
Browse files

NEW: Use HTTPError class.

  • Loading branch information...
1 parent d20c49f commit c96c54c82f76e5e52acbb9a30b53ceb0b4fbd9ed @lbdremy committed Feb 19, 2013
Showing with 2 additions and 17 deletions.
  1. +2 −17 lib/browser.js
View
@@ -7,8 +7,7 @@ var jsdom = require('jsdom'),
request = new require('superagent').agent(),
fs = require('fs'),
ScrapinodeError = require('./error/scrapinode-error'),
- http = require('http'),
- STATUS_CODES = http.STATUS_CODES;
+ HTTPError = require('httperror');
/**
* JQuery dependencies
@@ -73,7 +72,7 @@ function getRequest(options,callback){
// Check HTTP status code
var isHTTPError = isRedirect(res.status) || isClientError(res.status) || isServerError(res.status);
- if(isHTTPError) return onError(createHTTPError(res.status));
+ if(isHTTPError) return onError(new HTTPError(res.status));
// Attach event handlers and build the body
var body = '';
@@ -185,20 +184,6 @@ function isServerError(code){
}
/**
- * Create an `Èrror` object for the given HTTP status `code`.
- *
- * @param {Number} code
- * @return {Error}
- * @api private
- */
-
-function createHTTPError(code){
- var description = STATUS_CODES[code] || 'Unknown status code';
- var message = 'HTTP Error ' + code + ' - ' + description;
- return new Error(message);
-}
-
-/**
* Check if the content of the HTTP body is an image
*
* @param {Object} headers -

0 comments on commit c96c54c

Please sign in to comment.