Skip to content

Commit a2ec929

Browse files
committedNov 29, 2017
chore: remove code handling response JSON parsing errors
If GitHub sends us corrupt JSON, we have whole different kind of problems. This very much looks like code that was created because in theory it could happen, but even if it does, it will throw an 500 error which is what we’ll get for corrupt JSON anyway
1 parent d9bdadf commit a2ec929

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed
 

‎lib/index.js

+8-17
Original file line numberDiff line numberDiff line change
@@ -818,26 +818,17 @@ var Client = module.exports = function (config) {
818818
return self.sendError(err, msg, null, callback)
819819
}
820820

821-
var ret
822-
try {
823-
var data = res.data
821+
var data = res.data
824822

825-
var contentType = res.headers['content-type']
826-
if (contentType && contentType.indexOf('application/json') !== -1) {
827-
data = res.data && JSON.parse(res.data)
828-
}
829-
ret = {data: data}
830-
} catch (ex) {
831-
if (callback) {
832-
callback(new error.InternalServerError(ex.message), res)
833-
}
834-
return
823+
var contentType = res.headers['content-type']
824+
if (contentType && contentType.indexOf('application/json') !== -1) {
825+
data = res.data && JSON.parse(res.data)
835826
}
836-
837-
if (!ret) {
838-
ret = {}
827+
var ret = {
828+
data: data,
829+
meta: {}
839830
}
840-
ret.meta = {}
831+
841832
self.responseHeaders.forEach(function (header) {
842833
if (res.headers[header]) {
843834
ret.meta[header] = res.headers[header]

0 commit comments

Comments
 (0)
Please sign in to comment.