Closed eduardoboucas closed 8 years ago
Looks execellent. Love the detail in your pull request also! On Sun, 21 Feb 2016 at 10:54, Eduardo Bouças notifications@github.com wrote:
This implements error responses as per #7 https://github.com/dadi/passport/issues/7. Errors that happen when requesting a new token will make the Promise reject, sending back an object following the JSON API format http://jsonapi.org/format/#errors.
Example:
//
passport
was initialised with an incorrect URLpassport.then(function (bearer) { console.log('Bearer token: ' + bearer); }).catch(function (error) { console.log(error); });Returns:
{ status: 'Not found', title: 'URL not found', detail: 'The request for URL \'http://fake-api.eb.dev.dadi.technology/token\' returned a 404.', code: '' }
So far it's forming proper error objects for 401 and 404 only, so I suppose the next step is to make it handle more types of error.
@jimlambie https://github.com/jimlambie are you happy with this?
You can view, comment on, or merge this pull request online at:
https://github.com/dadi/passport/pull/9 Commit Summary
- Add error handling
File Changes
- M index.js https://github.com/dadi/passport/pull/9/files#diff-0 (26)
Patch Links:
— Reply to this email directly or view it on GitHub https://github.com/dadi/passport/pull/9.
Great! Merging. (cc @josephdenne)
This implements error responses as per #7. Errors that happen when requesting a new token will make the Promise reject, sending back an object following the JSON API format.
Example:
Returns:
So far it's forming proper error objects for
401
and404
only, so I suppose the next step is to make it handle more types of error.@jimlambie are you happy with this?