]> git.saurik.com Git - cycript.git/commitdiff
Error instances that weren't thrown have no stack.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 23 Dec 2015 19:39:06 +0000 (11:39 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 23 Dec 2015 19:39:06 +0000 (11:39 -0800)
libcycript.cy

index dd7e2ac1aa43314c86b6528137d167dbcc64ffba..8640a7490e7bc83e3d4c5629d9a5be2bcd56b9f6 100644 (file)
@@ -49,12 +49,19 @@ $cy_set(Date.prototype, {
 
 $cy_set(Error.prototype, {
     toCYON: function() {
-        let stack = this.stack.split('\n');
-        if (stack.slice(-1)[0] == "global code")
-            stack = stack.slice(0, -1);
-        for (let i = 0; i != stack.length; ++i)
-            stack[i] = '\n    ' + stack[i];
-        return `new ${this.constructor.name}(${this.message.toCYON()}) /*${stack.join('')} */`;
+        let stack = this.stack;
+        if (typeof stack == 'undefined')
+            stack = '';
+        else {
+            stack = stack.split('\n');
+            if (stack.slice(-1)[0] == "global code")
+                stack = stack.slice(0, -1);
+            for (let i = 0; i != stack.length; ++i)
+                stack[i] = '\n    ' + stack[i];
+            stack = stack.join('');
+            stack = ` /*${stack} */`;
+        }
+        return `new ${this.constructor.name}(${this.message.toCYON()})${stack}`;
     },
 });