Permalink
Browse files

Wrap error for more informative message.

  • Loading branch information...
1 parent 5a001de commit 95a53b820374e767b04b1aade9b45f7091234d89 @jaredhanson committed Jan 25, 2013
Showing with 6 additions and 2 deletions.
  1. +3 −2 lib/passport-netflix/strategy.js
  2. +3 −0 test/strategy-test.js
@@ -4,7 +4,8 @@
var xml2js = require('xml2js')
, querystring = require('querystring')
, util = require('util')
- , OAuthStrategy = require('passport-oauth').OAuthStrategy;
+ , OAuthStrategy = require('passport-oauth').OAuthStrategy
+ , InternalOAuthError = require('passport-oauth').InternalOAuthError;
/**
@@ -80,7 +81,7 @@ Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
// profile.id = params.user_id
this._oauth.get('http://api.netflix.com/users/' + params.user_id, token, tokenSecret, function (err, body, res) {
- if (err) { return done(err); }
+ if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }
var parser = new xml2js.Parser();
parser.parseString(body, function (err, xml) {
@@ -161,6 +161,9 @@ vows.describe('NetflixStrategy').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 95a53b8

Please sign in to comment.