Permalink
Browse files

Wrap error for more informative messages.

  • Loading branch information...
1 parent d29636b commit 1b3f603af376eb707b52032ddeee8c18402ff630 @jaredhanson committed Apr 1, 2012
Showing with 6 additions and 2 deletions.
  1. +3 −2 lib/passport-facebook/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;
/**
@@ -77,7 +78,7 @@ util.inherits(Strategy, OAuth2Strategy);
*/
Strategy.prototype.userProfile = function(accessToken, done) {
this._oauth2.getProtectedResource('https://graph.facebook.com/me', 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('FacebookStrategy').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 1b3f603

Please sign in to comment.