Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Wrap error for more informative messages.

  • Loading branch information...
commit fdd51486d665e3d50412b1e9e202a7d197e9b5f2 1 parent ce4a990
Jared Hanson authored
Showing with 6 additions and 2 deletions.
  1. +3 −2 lib/passport-twitter/strategy.js
  2. +3 −0  test/strategy-test.js
5 lib/passport-twitter/strategy.js
View
@@ -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;
/**
@@ -103,7 +104,7 @@ Strategy.prototype.authenticate = function(req) {
Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
if (!this._skipExtendedUserProfile) {
this._oauth.get('https://api.twitter.com/1/users/show.json?user_id=' + 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)); }
try {
var json = JSON.parse(body);
3  test/strategy-test.js
View
@@ -99,6 +99,9 @@ vows.describe('TwitterStrategy').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);
},
Please sign in to comment.
Something went wrong with that request. Please try again.