Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 76492104FD for ; Sat, 31 Aug 2013 18:44:52 +0000 (UTC) Received: (qmail 90155 invoked by uid 500); 31 Aug 2013 18:44:52 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 89601 invoked by uid 500); 31 Aug 2013 18:44:49 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 89418 invoked by uid 99); 31 Aug 2013 18:44:48 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Aug 2013 18:44:48 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id EFF368BA715; Sat, 31 Aug 2013 18:44:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Message-Id: <57694bea134448ff8c7af5d88de75b66@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) 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 Authored: Sat Aug 31 14:44:06 2013 -0400 Committer: Andrew Grieve 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(); } } }