backandsdk
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -174,7 +174,30 @@ /* | ||
}; | ||
BackandSdk.prototype.formatErrorMessage = function(response, error) { | ||
var str = ""; | ||
if(response.statusCode){ | ||
str += 'Status code: "' + response.statusCode + " "; | ||
} | ||
if(typeof response.body === 'object'){ | ||
str += JSON.stringify(response.body); | ||
}else { | ||
str += response.body; | ||
} | ||
str += " "; | ||
if(response.request && response.request.href) { | ||
str += ' requestUrl: ' + response.request.href; | ||
} | ||
if(error) { | ||
str += error; | ||
} | ||
return str; | ||
} | ||
BackandSdk.prototype.handleResponse = function (deferred, error, response, data) { | ||
if (error || response.statusCode != 200) { | ||
error = 'Status code: "' + response.statusCode + ' "' + | ||
typeof response.body === 'object' ? JSON.stringify(response.body) : response.body + (response.request ? ' requestUrl: ' + response.request.href : ''); | ||
error = this.formatErrorMessage(response, error); | ||
console.error('Error: ', error); | ||
@@ -181,0 +204,0 @@ deferred.reject(error); |
{ | ||
"name": "backandsdk", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Backand sdk for node.js", | ||
@@ -5,0 +5,0 @@ "author": "Ygal Bellaiche", |
18743
14
571