incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [3/40] git commit: safe JSON parsing of results in CordovaCommandResult, exec has TODO item for named parameter mappings
Date Fri, 06 Apr 2012 01:20:42 GMT
safe JSON parsing of results in CordovaCommandResult, exec has TODO item for named parameter
mappings


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/0844a730
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/0844a730
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/0844a730

Branch: refs/heads/master
Commit: 0844a7301e9e4044dd9350492549ec295087ecd8
Parents: c902b74
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Thu Apr 5 14:22:46 2012 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Thu Apr 5 14:22:46 2012 -0700

----------------------------------------------------------------------
 lib/wp7/exec.js                            |   17 +++++++++++++++++
 lib/wp7/plugin/wp7/CordovaCommandResult.js |   16 ++++++++++++++--
 2 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0844a730/lib/wp7/exec.js
----------------------------------------------------------------------
diff --git a/lib/wp7/exec.js b/lib/wp7/exec.js
index 2079ebc..6b1f929 100644
--- a/lib/wp7/exec.js
+++ b/lib/wp7/exec.js
@@ -16,6 +16,23 @@ var cordova = require('cordova');
 
  */
  
+ /* this will become a programmatic way to gen the named args ... TODO: -jm
+var NamedArgs = 
+{
+	File:{
+		getFileMetadata:["fullPath"],
+		readAsText:["fileName","encoding"],
+		readAsDataURL:["fileName"],
+		getDirectory:["fullPath","path","options"],
+		removeRecursively:["fullPath"],
+		getFile:["fullPath","path","options"],
+		readEntries:["fullPath"],
+		write:["fileName","data","position"],
+		truncate:["fileName","size"]
+	}
+}
+*/
+ 
 var MonkeyPatch = 
 {
 	File:

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0844a730/lib/wp7/plugin/wp7/CordovaCommandResult.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/CordovaCommandResult.js b/lib/wp7/plugin/wp7/CordovaCommandResult.js
index 6798457..e166258 100644
--- a/lib/wp7/plugin/wp7/CordovaCommandResult.js
+++ b/lib/wp7/plugin/wp7/CordovaCommandResult.js
@@ -18,7 +18,18 @@ module.exports = function(status,callbackId,args,cast) {
 		return "true";  
 	}
 	
-	var parsedArgs = JSON.parse(args);
+	var parsedArgs;
+	try
+	{
+		parsedArgs = JSON.parse(args);
+		
+	}
+	catch(ex)
+	{
+		console.log("Parse error in CordovaCommandResult :: " + ex);
+		return;
+	}
+	
 	try
 	{
 		// For some commands, the message is a JSON encoded string
@@ -26,8 +37,9 @@ module.exports = function(status,callbackId,args,cast) {
 		// case where message was indeed, just a string.
 		parsedArgs.message = JSON.parse(parsedArgs.message);
 	}
-	catch(e)
+	catch(ex)
 	{
+
 	}
 	var safeStatus = parseInt(status, 10);
 	if(safeStatus === cordova.callbackStatus.NO_RESULT ||


Mime
View raw message