error reporting
authorDominqique Hazael-Massieux <dom@w3.org>
Thu, 01 Sep 2011 12:02:12 +0200
changeset 209 96dd338b6730
parent 208 d815783a4272
child 210 dc44f5d58e90
error reporting
node.js/twitter.js
--- a/node.js/twitter.js	Thu Sep 01 11:32:41 2011 +0200
+++ b/node.js/twitter.js	Thu Sep 01 12:02:12 2011 +0200
@@ -56,13 +56,13 @@
 	       'end',
 	       function () {
 		   if (response.statusCode != 200){
-  		       console.log("Looking twitter user id failed: " + response.statusCode + JSON.stringify(response.headers));		   
+		       callback("Looking twitter user id failed: " + response.statusCode + JSON.stringify(response.headers), null);
 		   } else {
 		       try {
 			   twitterData = JSON.parse(twitterDataJSON);
-			   callback(twitterData[0].id);
+			   callback(null, twitterData[0].id);
 		       } catch (err) {
-			   console.log(err);
+			   callback("Failed to parse response from Twitter API (" + err + ")", null);
 		       }
 		   }
 	       });