Skip to content

Commit

Permalink
Make ParseError construction more lenient
Browse files Browse the repository at this point in the history
JSON test 'should have statusCode in err' requires an instance of
ParseError to compare to but has no opts or data to pass. This commit
makes those arguments optional allowing for empty ParseError
construction.
  • Loading branch information
alextes committed Feb 14, 2017
1 parent 39bf828 commit 621c311
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ function stdError(error, opts) {

got.RequestError = createErrorClass('RequestError', stdError);
got.ReadError = createErrorClass('ReadError', stdError);
got.ParseError = createErrorClass('ParseError', function (e, statusCode, opts, data) {
got.ParseError = createErrorClass('ParseError', function (e, statusCode) {
const opts = arguments.length > 2 && typeof arguments[2] !== 'undefined' ? arguments[2] : {};
const data = arguments.length > 3 && typeof arguments[3] !== 'undefined' ? arguments[3] : '';
stdError.call(this, e, opts);
this.statusCode = statusCode;
this.statusMessage = http.STATUS_CODES[this.statusCode];
Expand Down

0 comments on commit 621c311

Please sign in to comment.