Skip to content

Commit

Permalink
Adding response body to the FigureError Class, bump to version 0.2.33
Browse files Browse the repository at this point in the history
* Adding response body to the error data

* new version in package.json
  • Loading branch information
yzalbj authored Dec 19, 2019
1 parent 2e3f50c commit 83bb1fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions lib/Error.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ _Error.extend = utils.protoExtend;
var FigureError = _Error.FigureError = _Error.extend({
type: 'figure_error',
populate: function(raw) {
// Move from prototype def (so it appears in stringified obj)
// Move from prototype def (so it appears in stringified obj)
this.type = this.type;
this.stack = (new Error(raw.message)).stack;
this.status = raw.status;
this.message = raw.message;
this.text = raw.text;
this.raw = raw;
this.stack = (new Error(raw.error.message)).stack;
this.status = raw.error.status;
this.message = raw.error.message;
this.text = raw.error.text;
this.body = raw.body;
this.raw = raw.error;
},
});

Expand Down
2 changes: 1 addition & 1 deletion lib/FigureResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ FigureResource.prototype = {
callback(new Error.FigureConnectionError(err), null)
} else if (err && res && res.error) {
// throw different errors based on res.error.status
self._errorHandler(res.error, callback);
self._errorHandler(res, callback);
} else if (err) {
// unknown error
callback(new Error.FigureError(err), null)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "figure-sdk",
"version": "0.2.32",
"version": "0.2.33",
"description": "The Figure JavaScript SDK",
"main": "lib/figure.js",
"homepage": "https://github.com/postcard/figure-sdk-node",
Expand Down

0 comments on commit 83bb1fb

Please sign in to comment.