diff --git a/app/jxcore_cordova.js b/app/jxcore_cordova.js
index 5b23c9c..4ee4b15 100644
--- a/app/jxcore_cordova.js
+++ b/app/jxcore_cordova.js
@@ -180,9 +180,9 @@ internal_methods['loadMainFile'] = function (filePath, callback_) {
require(path.join(process.cwd(), filePath));
} catch (e) {
result = false;
+ Error.captureStackTrace(e);
err = e;
- Error.captureStackTrace(err);
- console.error("loadMainFile", e);
+ JXMobile('OnError').callNative(e.message, JSON.stringify(e.stack));
}
callback_(result, !err ? null : err.message + "\n" + err.stack);
};
@@ -192,39 +192,43 @@ JXMobile.executeJSON = function (json, callbackId) {
var internal = internal_methods[json.methodName];
var fnc = jx_methods[json.methodName];
-
- if (internal) {
- var cb = new MakeCallback(callbackId).callback
- json.params.push(cb);
- internal.apply(null, json.params);
- return;
- } else if (fnc) {
- if (!fnc.is_synced) {
- if (!json.params || (json.params.length == 1 && json.params[0] === null)) {
- json.params = [];
+ try {
+ if (internal) {
+ var cb = new MakeCallback(callbackId).callback
+ json.params.push(cb);
+ internal.apply(null, json.params);
+ return;
+ } else if (fnc) {
+ if (!fnc.is_synced) {
+ if (!json.params || (json.params.length == 1 && json.params[0] === null)) {
+ json.params = [];
+ }
+ json.params[json.params.length] = new MakeCallback(callbackId).callback;
}
- json.params[json.params.length] = new MakeCallback(callbackId).callback;
- }
- var ret_val = fnc.method.apply(null, json.params);
- if (fnc.is_synced && callbackId) {
- new MakeCallback(callbackId).callback(ret_val);
- } else {
- return ret_val;
- }
- return;
- } else if (json.methodName && json.methodName.length>3 && json.methodName.substr(0,3) === "RC-") {
- var cb = new MakeCallback(callbackId).callback
- json.params.push(cb);
- fnc = ui_methods[json.methodName.substr(3)];
- if (fnc && fnc.returnCallback) {
- fnc.returnCallback.apply(null, json.params);
- delete ui_methods[json.methodName.substr(3)];
+ var ret_val = fnc.method.apply(null, json.params);
+ if (fnc.is_synced && callbackId) {
+ new MakeCallback(callbackId).callback(ret_val);
+ } else {
+ return ret_val;
+ }
return;
+ } else if (json.methodName && json.methodName.length>3 && json.methodName.substr(0,3) === "RC-") {
+ var cb = new MakeCallback(callbackId).callback
+ json.params.push(cb);
+ fnc = ui_methods[json.methodName.substr(3)];
+ if (fnc && fnc.returnCallback) {
+ fnc.returnCallback.apply(null, json.params);
+ delete ui_methods[json.methodName.substr(3)];
+ return;
+ }
}
- }
- console.error("JXcore: Method Doesn't Exist [", json.methodName, "] Did you register it?");
+ throw new Error("JXcore: Method Doesn't Exist [", json.methodName, "] Did you register it?");
+ } catch(e) {
+ Error.captureStackTrace(e);
+ JXMobile('OnError').callNative(e.message, JSON.stringify(e.stack));
+ }
};
console.warn("Platform", process.platform);
@@ -421,4 +425,9 @@ if (isAndroid) {
jxcore.tasks.register(process.setPaths);
}
+process.on('uncaughtException', function (e) {
+ Error.captureStackTrace(e);
+ JXMobile('OnError').callNative(e.message, JSON.stringify(e.stack));
+});
+
console.log("JXcore Cordova bridge is ready!");
\ No newline at end of file
diff --git a/plugin.xml b/plugin.xml
index 7843f41..47f551d 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -26,6 +26,8 @@
+
+
@@ -58,6 +60,7 @@
+
diff --git a/src/android/java/io/jxcore/node/JXMobile.java b/src/android/java/io/jxcore/node/JXMobile.java
new file mode 100644
index 0000000..6902a78
--- /dev/null
+++ b/src/android/java/io/jxcore/node/JXMobile.java
@@ -0,0 +1,25 @@
+// License information is available from LICENSE file
+
+package io.jxcore.node;
+
+import io.jxcore.node.jxcore.JXcoreCallback;
+
+import java.util.ArrayList;
+
+import android.annotation.SuppressLint;
+import android.util.Log;
+
+public class JXMobile {
+ public static void Initialize() {
+ jxcore.RegisterMethod("OnError", new JXcoreCallback() {
+ @SuppressLint("NewApi")
+ @Override
+ public void Receiver(ArrayList