Skip to content

Commit

Permalink
Wrap error for informative messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Apr 28, 2012
1 parent c18ed12 commit 3901b76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/passport-tumblr/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Module dependencies.
*/
var util = require('util')
, OAuthStrategy = require('passport-oauth').OAuthStrategy;
, OAuthStrategy = require('passport-oauth').OAuthStrategy
, InternalOAuthError = require('passport-oauth').InternalOAuthError;


/**
Expand Down Expand Up @@ -70,7 +71,7 @@ util.inherits(Strategy, OAuthStrategy);
*/
Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
this._oauth.get('http://api.tumblr.com/v2/user/info', token, tokenSecret, 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);
Expand Down
3 changes: 3 additions & 0 deletions test/strategy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ vows.describe('TumblrStrategy').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);
},
Expand Down

0 comments on commit 3901b76

Please sign in to comment.