Skip to content
Browse files

Wrap error for informative messages.

  • Loading branch information...
1 parent 0ac93ae commit b47b2c4a6da729484c362f4b47f2b479834bf27f @jaredhanson committed Apr 29, 2012
Showing with 6 additions and 2 deletions.
  1. +3 −2 lib/passport-linkedin/strategy.js
  2. +3 −0 test/strategy-test.js
View
5 lib/passport-linkedin/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;
/**
@@ -95,7 +96,7 @@ Strategy.prototype.authenticate = function(req) {
*/
Strategy.prototype.userProfile = function(token, tokenSecret, params, done) {
this._oauth.get('https://api.linkedin.com/v1/people/~:(id,first-name,last-name)?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
@@ -100,6 +100,9 @@ vows.describe('LinkedInStrategy').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 b47b2c4

Please sign in to comment.
Something went wrong with that request. Please try again.