diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java index e3440d18a..1541318e7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSDebuggerWebSocketClient.java @@ -20,6 +20,7 @@ import java.util.concurrent.TimeUnit; import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; +import com.facebook.react.common.JavascriptException; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; @@ -212,6 +213,10 @@ public class JSDebuggerWebSocketClient implements WebSocketListener { } else if ("result".equals(field)) { parser.nextToken(); result = parser.getText(); + } else if ("error".equals(field)) { + parser.nextToken(); + String error = parser.getText(); + abort(error, new JavascriptException(error)); } } if (replyID != null) { diff --git a/local-cli/server/util/debuggerWorker.js b/local-cli/server/util/debuggerWorker.js index b5dcd27bd..24a3c0f36 100644 --- a/local-cli/server/util/debuggerWorker.js +++ b/local-cli/server/util/debuggerWorker.js @@ -15,16 +15,21 @@ var messageHandlers = { for (var key in message.inject) { self[key] = JSON.parse(message.inject[key]); } - importScripts(message.url); - sendReply(); + let error; + try { + importScripts(message.url); + } catch (err) { + error = JSON.stringify(err); + } + sendReply(null /* result */, error); } }; onmessage = function(message) { var object = message.data; - var sendReply = function(result) { - postMessage({replyID: object.id, result: result}); + var sendReply = function(result, error) { + postMessage({replyID: object.id, result: result, error: error}); }; var handler = messageHandlers[object.method];