summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-firebasex/src/android/JavaScriptException.java
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-08-31 23:07:20 +0200
committerJules Laplace <julescarbon@gmail.com>2020-08-31 23:07:20 +0200
commit22721a013bdd10d5eb395ba18453585f5f3f1f7f (patch)
tree5a920e31d6026ed5dc55265e5fd057febccc50e3 /StoneIsland/plugins/cordova-plugin-firebasex/src/android/JavaScriptException.java
parentd22d51a1ae49680015326857360eb699f31efced (diff)
rebuild the ios platform and the plugins
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-firebasex/src/android/JavaScriptException.java')
-rw-r--r--StoneIsland/plugins/cordova-plugin-firebasex/src/android/JavaScriptException.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-firebasex/src/android/JavaScriptException.java b/StoneIsland/plugins/cordova-plugin-firebasex/src/android/JavaScriptException.java
new file mode 100644
index 00000000..3d423fa3
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-firebasex/src/android/JavaScriptException.java
@@ -0,0 +1,45 @@
+package org.apache.cordova.firebase;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * Exception class to log Javascript based exceptions with stacktrace.
+ *
+ * Picked from https://github.com/wizpanda/cordova-plugin-firebase-lib/pull/8/files
+ *
+ * @author https://github.com/sagrawal31/
+ */
+public class JavaScriptException extends Exception {
+
+ public JavaScriptException(String message) {
+ super(message);
+ }
+
+ public JavaScriptException(String message, JSONArray stackTrace) throws JSONException {
+ super(message);
+ this.handleStacktrace(stackTrace);
+ }
+
+ private void handleStacktrace(JSONArray stackTrace) throws JSONException {
+ if (stackTrace == null) {
+ return;
+ }
+
+ StackTraceElement[] trace = new StackTraceElement[stackTrace.length()];
+
+ for (int i = 0; i < stackTrace.length(); i++) {
+ JSONObject elem = stackTrace.getJSONObject(i);
+
+ trace[i] = new StackTraceElement(
+ "undefined",
+ elem.optString("functionName", "undefined"),
+ elem.optString("fileName", "undefined"),
+ elem.optInt("lineNumber", -1)
+ );
+ }
+
+ this.setStackTrace(trace);
+ }
+}