Commit b00dfeed authored by nanahira's avatar nanahira

update error handle

parent 1a68e066
......@@ -127,10 +127,17 @@ Client.prototype.makeRequest = function(obj) {
}
// 200 ok
if (self.options.get('format') == 'json') {
resData = JSON.parse(resData);
if (self.options.get('massageProperties')) {
resData = util.convert(resData, util.underscoreToCamel);
var _resData = resData;
try {
resData = JSON.parse(resData);
if (self.options.get('massageProperties')) {
resData = util.convert(resData, util.underscoreToCamel);
}
} catch (err) {
errorHandler.handle(res, _resData, callback, self.options.get('format'));
return;
}
}
callback(null, resData); //no error, so no err object
});
......@@ -138,7 +145,13 @@ Client.prototype.makeRequest = function(obj) {
req.on('error', (e) => {
callback(e, null);
const err = {
error: true,
errors: [e],
statusCode: 0,
text: 'Request error'
};
callback(err, null);
});
req.on('timeout', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment