Permalink
Browse files

Merge pull request #12 from jamescharlesworth/master

Handle invalid logins
  • Loading branch information...
2 parents 5e2b4af + 707693f commit 0f7252059aa492b0ac4363eaf10a3ea5234ef15c @ncb000gt committed Oct 26, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/ga.js
View
@@ -49,6 +49,11 @@ GA.prototype.login = function(cb) {
var self = this;
this.on('token', this.captureToken);
+ //handle invalid login errors
+ this.on('error', function(err){
+ cb(err, null);
+ });
+
if (cb) this.on('token', cb);
var postData = {
@@ -122,7 +127,7 @@ GA.prototype.get = function(options, cb) {
,dimension_index;
var data_data = combineChunks(chunks, length).toString();
-
+
var parsed_data = JSON.parse(data_data);
for (var col=0; col<parsed_data.columnHeaders.length; col++){
@@ -154,7 +159,7 @@ GA.prototype.get = function(options, cb) {
}
if (typeof cb === 'function' ) cb(null, entries);
-
+
});
});
req.end();

0 comments on commit 0f72520

Please sign in to comment.