cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject js commit: Revert "[android] Don't catch exceptions wihtin the bridge since the browser does better logging of them when uncaught."
Date Sat, 31 Aug 2013 18:44:45 GMT
Updated Branches:
  refs/heads/master 8937f29ee -> 0ab1d2bd2


Revert "[android] Don't catch exceptions wihtin the bridge since the browser does better logging
of them when uncaught."

This reverts commit 8937f29ee8aa58568db94865860c86615acf23ca.

I checked it in too hastily. It doesn't actually work as I wanted. Needs
more thinking...


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

Branch: refs/heads/master
Commit: 0ab1d2bd2e44e0e42bcb12c3fbd8f461eb7e84f4
Parents: 8937f29
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Sat Aug 31 14:44:06 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Sat Aug 31 14:44:06 2013 -0400

----------------------------------------------------------------------
 lib/android/exec.js | 89 +++++++++++++++++++++++++-----------------------
 1 file changed, 46 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/0ab1d2bd/lib/android/exec.js
----------------------------------------------------------------------
diff --git a/lib/android/exec.js b/lib/android/exec.js
index a68608f..0d35ff1 100644
--- a/lib/android/exec.js
+++ b/lib/android/exec.js
@@ -169,44 +169,50 @@ androidExec.setNativeToJsBridgeMode = function(mode) {
 
 // Processes a single message, as encoded by NativeToJsMessageQueue.java.
 function processMessage(message) {
-    var firstChar = message.charAt(0);
-    if (firstChar == 'J') {
-        eval(message.slice(1));
-    } else if (firstChar == 'S' || firstChar == 'F') {
-        var success = firstChar == 'S';
-        var keepCallback = message.charAt(1) == '1';
-        var spaceIdx = message.indexOf(' ', 2);
-        var status = +message.slice(2, spaceIdx);
-        var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
-        var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
-        var payloadKind = message.charAt(nextSpaceIdx + 1);
-        var payload;
-        if (payloadKind == 's') {
-            payload = message.slice(nextSpaceIdx + 2);
-        } else if (payloadKind == 't') {
-            payload = true;
-        } else if (payloadKind == 'f') {
-            payload = false;
-        } else if (payloadKind == 'N') {
-            payload = null;
-        } else if (payloadKind == 'n') {
-            payload = +message.slice(nextSpaceIdx + 2);
-        } else if (payloadKind == 'A') {
-            var data = message.slice(nextSpaceIdx + 2);
-            var bytes = window.atob(data);
-            var arraybuffer = new Uint8Array(bytes.length);
-            for (var i = 0; i < bytes.length; i++) {
-                arraybuffer[i] = bytes.charCodeAt(i);
+    try {
+        var firstChar = message.charAt(0);
+        if (firstChar == 'J') {
+            eval(message.slice(1));
+        } else if (firstChar == 'S' || firstChar == 'F') {
+            var success = firstChar == 'S';
+            var keepCallback = message.charAt(1) == '1';
+            var spaceIdx = message.indexOf(' ', 2);
+            var status = +message.slice(2, spaceIdx);
+            var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
+            var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
+            var payloadKind = message.charAt(nextSpaceIdx + 1);
+            var payload;
+            if (payloadKind == 's') {
+                payload = message.slice(nextSpaceIdx + 2);
+            } else if (payloadKind == 't') {
+                payload = true;
+            } else if (payloadKind == 'f') {
+                payload = false;
+            } else if (payloadKind == 'N') {
+                payload = null;
+            } else if (payloadKind == 'n') {
+                payload = +message.slice(nextSpaceIdx + 2);
+            } else if (payloadKind == 'A') {
+                var data = message.slice(nextSpaceIdx + 2);
+                var bytes = window.atob(data);
+                var arraybuffer = new Uint8Array(bytes.length);
+                for (var i = 0; i < bytes.length; i++) {
+                    arraybuffer[i] = bytes.charCodeAt(i);
+                }
+                payload = arraybuffer.buffer;
+            } else if (payloadKind == 'S') {
+                payload = window.atob(message.slice(nextSpaceIdx + 2));
+            } else {
+                payload = JSON.parse(message.slice(nextSpaceIdx + 1));
             }
-            payload = arraybuffer.buffer;
-        } else if (payloadKind == 'S') {
-            payload = window.atob(message.slice(nextSpaceIdx + 2));
+            cordova.callbackFromNative(callbackId, success, status, [payload], keepCallback);
         } else {
-            payload = JSON.parse(message.slice(nextSpaceIdx + 1));
+            console.log("processMessage failed: invalid message:" + message);
         }
-        cordova.callbackFromNative(callbackId, success, status, [payload], keepCallback);
-    } else {
-        console.log("processMessage failed: invalid message:" + message);
+    } catch (e) {
+        console.log("processMessage failed: Message: " + message);
+        console.log("processMessage failed: Error: " + e);
+        console.log("processMessage failed: Stack: " + e.stack);
     }
 }
 
@@ -233,14 +239,11 @@ androidExec.processMessages = function(messages) {
             var msgLen = +messages.slice(0, spaceIdx);
             var message = messages.substr(spaceIdx + 1, msgLen);
             messages = messages.slice(spaceIdx + msgLen + 1);
-            try {
-                processMessage(message);
-            } finally {
-                if (messages) {
-                    messagesFromNative[0] = messages;
-                } else {
-                    messagesFromNative.shift();
-                }
+            processMessage(message);
+            if (messages) {
+                messagesFromNative[0] = messages;
+            } else {
+                messagesFromNative.shift();
             }
         }
     }


Mime
View raw message