Permalink
Browse files

error handling

  • Loading branch information...
1 parent b5c1503 commit 6cebb29d79a52d89eedb14ef91ea828146e5922b @qzaidi qzaidi committed Nov 29, 2012
Showing with 15 additions and 1 deletion.
  1. +7 −1 examples/basic.js
  2. +8 −0 lib/ga.js
View
@@ -18,6 +18,12 @@ GA.login(function(err, token) {
'sort': '-ga:pagePath'
};
GA.get(options, function(err, entries) {
- console.log(entries);
+ if (!err) {
+ entries.forEach(function(entry) {
+ console.log(entry);
+ });
+ } else {
+ console.log(err);
+ }
});
});
View
@@ -127,6 +127,14 @@ GA.prototype.get = function(options, cb) {
var parsed_data = JSON.parse(data_data);
+ if (parsed_data.error) {
+ var err = new Error(parsed_data.error.message);
+ //self.emit('error',err);
+ if (typeof cb === 'function' ) {
+ return cb(err);
+ }
+ }
+
for (var col=0; col<parsed_data.columnHeaders.length; col++){
if(parsed_data.columnHeaders[col]['columnType'] === "METRIC"){
metric_indexes.push(col);

0 comments on commit 6cebb29

Please sign in to comment.