Permalink
Browse files

Wrap error for informative messages.

  • Loading branch information...
1 parent da15177 commit 2cf2a8842a00b2adfdae05628ceb920c034268e5 @jaredhanson committed Jan 23, 2013
Showing with 6 additions and 2 deletions.
  1. +3 −2 lib/passport-yammer/strategy.js
  2. +3 −0 test/strategy-test.js
@@ -3,7 +3,8 @@
*/
var querystring = require('querystring')
, util = require('util')
- , OAuth2Strategy = require('passport-oauth').OAuth2Strategy;
+ , OAuth2Strategy = require('passport-oauth').OAuth2Strategy
+ , InternalOAuthError = require('passport-oauth').InternalOAuthError;
/**
@@ -100,7 +101,7 @@ util.inherits(Strategy, OAuth2Strategy);
*/
Strategy.prototype.userProfile = function(accessToken, done) {
this._oauth2.get(this._userProfileURL, 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
@@ -145,6 +145,9 @@ vows.describe('YammerStrategy').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 2cf2a88

Please sign in to comment.