Comparing version 1.1.2 to 1.1.3
@@ -106,10 +106,16 @@ /** | ||
if (callback) { | ||
var data = err || !body ? {} : JSON.parse(body); | ||
var data; | ||
try { | ||
data = err || !body ? {status: 500, message: 'Empty body'} : JSON.parse(body); | ||
} catch (e) { | ||
data = { status: 500, message: (e.message || 'Invalid JSON body') }; | ||
} | ||
//request doesn't think 4xx is an error - we want an error for any non-2xx status codes | ||
if (!err && (response.statusCode < 200 || response.statusCode > 206)) { | ||
err = data ? data : { | ||
status: response.statusCode, | ||
message:'HTTP request error, check response for more info' | ||
}; | ||
var error = null; | ||
if (err || (response.statusCode < 200 || response.statusCode > 206)) { | ||
error = { status: response.statusCode }; | ||
error.message = data ? data.message : 'HTTP request error, check response for more info'; | ||
error.code = data && data.code; | ||
error.moreInfo = data && data.more_info; | ||
} | ||
@@ -152,3 +158,3 @@ | ||
callback.call(client, err, data, response); | ||
callback.call(client, error, data, response); | ||
} | ||
@@ -155,0 +161,0 @@ }); |
{ | ||
"name":"twilio", | ||
"description":"A Twilio helper library", | ||
"version":"1.1.2", | ||
"version":"1.1.3", | ||
"author":"Kevin Whinnery <kevin.whinnery@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors":[ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42459
790