Skip to content

Commit

Permalink
remove parse-json
Browse files Browse the repository at this point in the history
Closes #134
  • Loading branch information
floatdrop committed Dec 2, 2015
1 parent d5d19ce commit 95b4f8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 6 additions & 5 deletions index.js
Expand Up @@ -17,7 +17,6 @@ const unzipResponse = require('unzip-response');
const createErrorClass = require('create-error-class');
const nodeStatusCodes = require('node-status-codes');
const isPlainObj = require('is-plain-obj');
const parseJson = require('parse-json');

function requestAsEventEmitter(opts) {
opts = opts || {};
Expand Down Expand Up @@ -103,10 +102,9 @@ function asCallback(opts, cb) {

if (opts.json && statusCode !== 204) {
try {
data = parseJson(data);
data = JSON.parse(data);
} catch (e) {
e.fileName = urlLib.format(opts);
err = new got.ParseError(e, opts);
err = new got.ParseError(e, opts, data);
}
}

Expand Down Expand Up @@ -346,7 +344,10 @@ function stdError(error, opts) {

got.RequestError = createErrorClass('RequestError', stdError);
got.ReadError = createErrorClass('ReadError', stdError);
got.ParseError = createErrorClass('ParseError', stdError);
got.ParseError = createErrorClass('ParseError', function (e, opts, data) {
stdError.call(this, e, opts);
this.message = `${e.message} in "${urlLib.format(opts)}": \n${data.slice(0, 77)}...`;
});

got.HTTPError = createErrorClass('HTTPError', function (statusCode, opts) {
stdError.call(this, {}, opts);
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -54,7 +54,6 @@
"lowercase-keys": "^1.0.0",
"node-status-codes": "^1.0.0",
"object-assign": "^4.0.1",
"parse-json": "^2.1.0",
"timed-out": "^2.0.0",
"unzip-response": "^1.0.0",
"url-parse-lax": "^1.0.0"
Expand Down

0 comments on commit 95b4f8c

Please sign in to comment.