]> git.saurik.com Git - cycript.git/commitdiff
Include stack trace when printing Java exceptions.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 10 Jan 2016 07:34:15 +0000 (23:34 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 10 Jan 2016 07:34:15 +0000 (23:34 -0800)
libcycript.cy

index 57e8894a79ba7efaf966f597360dd424514a2e73..8240a44def2fb362e88748f0557aed905e750d9c 100644 (file)
@@ -184,6 +184,26 @@ Java.on('setup', function() {
                 this.put(key, value);
         },
     });
+
+    $cy_set(java.lang.Throwable.prototype, {
+        toCYON: function() {
+            var message = this.getMessage();
+            if (message == null)
+                message = '';
+            else
+                message = message.toCYON();
+
+            let stack = this.getStackTrace();
+            if (stack.length == 0)
+                stack = '';
+            else {
+                stack = stack.join('\n    ');
+                stack = ` /*\n    ${stack} */`;
+            }
+
+            return `new ${this.constructor.class.getName()}(${message})${stack}`;
+        },
+    });
 });
 
 }