Permalink
Browse files

Wrap error for more informative messages.

  • Loading branch information...
1 parent 794a867 commit 086b8c80ad33b86977c9fc3794a81932a516058d @jaredhanson committed May 5, 2012
Showing with 6 additions and 2 deletions.
  1. +3 −2 lib/passport-foursquare/strategy.js
  2. +3 −0 test/strategy-test.js
@@ -2,7 +2,8 @@
* Module dependencies.
*/
var util = require('util')
- , OAuth2Strategy = require('passport-oauth').OAuth2Strategy;
+ , OAuth2Strategy = require('passport-oauth').OAuth2Strategy
+ , InternalOAuthError = require('passport-oauth').InternalOAuthError;
/**
@@ -95,7 +96,7 @@ Strategy.prototype.userProfile = function(accessToken, done) {
url += '?v=' + this.apiVersion;
}
this._oauth2.get(url, accessToken, function (err, body, res) {
- if (err) { return done(err); }
+ if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }
try {
var json = JSON.parse(body);
View
@@ -105,6 +105,9 @@ vows.describe('FoursquareStrategy').addBatch({
'should error' : function(err, req) {
assert.isNotNull(err);
},
+ 'should wrap error in InternalOAuthError' : function(err, req) {
+ assert.equal(err.constructor.name, 'InternalOAuthError');
+ },
'should not load profile' : function(err, profile) {
assert.isUndefined(profile);
},

0 comments on commit 086b8c8

Please sign in to comment.