From dc15fe8ace017fdef39202474c1563c1ae0ae67a Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 9 Jan 2016 23:34:15 -0800 Subject: [PATCH] Include stack trace when printing Java exceptions. --- libcycript.cy | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libcycript.cy b/libcycript.cy index 57e8894..8240a44 100644 --- a/libcycript.cy +++ b/libcycript.cy @@ -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}`; + }, + }); }); } -- 2.47.2