Permalink
Browse files

Wrap error for informative message.

  • Loading branch information...
1 parent 32f8cb8 commit 5f8b1893ba90ffbf1046c7367d977da0fdbe6148 @jaredhanson committed Feb 9, 2013
Showing with 6 additions and 2 deletions.
  1. +3 −2 lib/passport-vimeo/strategy.js
  2. +3 −0 test/strategy-test.js
View
5 lib/passport-vimeo/strategy.js
@@ -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;
/**
@@ -72,7 +73,7 @@ util.inherits(Strategy, OAuthStrategy);
*/
Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
this._oauth.get('http://vimeo.com/api/rest/v2/?method=vimeo.people.getInfo&user_id=' + token + '&format=json', 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);
View
3 test/strategy-test.js
@@ -117,6 +117,9 @@ vows.describe('VimeoStrategy').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 5f8b189

Please sign in to comment.