Skip to content

Commit

Permalink
Merge pull request stripe#38 from onmodulus/master
Browse files Browse the repository at this point in the history
Added a few more properties to Errors returned from Stripe
  • Loading branch information
abh committed Mar 12, 2013
2 parents aaf14d5 + 4bbdb39 commit 62b7eca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ called with a Javascript `Error` (if any) and then the response.
* `.retrieve(id)` - [retrieve an event](https://stripe.com/docs/api#retrieve_event)
* `.list()` - [list all events](https://stripe.com/docs/api#list_events)

## Errors

Errors returned take the following format. [Stripe Errors](https://stripe.com/docs/api#errors)

{
name: "Stripe error type",
code: "Stripe error code",
param: "Stripe error param",
message: "Stripe error message"
}

## TODO

See the [issue tracker](http:https://github.com/abh/node-stripe).
Expand Down
2 changes: 2 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ function setup_response_handler(req, callback) {
if(200 != res.statusCode) {
err = new Error(response.error.message);
err.name = response.error.type;
err.code = response.error.code;
err.param = response.error.param;
response = null;
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ vows.describe("Error handling").addBatch({
assert.isNull(response);
assert.instanceOf(err, Error);
assert.equal(err.name, 'invalid_request_error');
assert.equal(err.code, undefined);
assert.equal(err.param, 'id');
assert.isNotNull(err.message);
},
},
Expand Down

0 comments on commit 62b7eca

Please sign in to comment.