From cfffd35f2da32abec0f5ad865144342f73fa092b Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 29 Oct 2020 17:58:35 -0400 Subject: Stack trace for runtime errors --- docs/repl.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'docs/repl.js') diff --git a/docs/repl.js b/docs/repl.js index da06e383..e9158b12 100644 --- a/docs/repl.js +++ b/docs/repl.js @@ -14,22 +14,23 @@ let repl = ()=>{ try { doc.rslt.textContent=fmt(bqn(s)); } catch(e) { - let r=e.src, w=e.message, is=null; - if (r==='Compiler'&&w.sh[0]===2) [is,w]=w; - if (r==='!') w=w?fmt(w).replace(/^/gm,'! '):'! Error'; - else w=w.sh?w.join(''):w; - if (is!==null) { + console.log(e); + let r=e.src, w=e.message, loc=[]; + while (w.sh&&w.sh[0]===2) { + let is; [is,w]=w; let n=is.sh?is.sh[0]:0, i=n?is[0]:is; let to=i=>Array.from(s).slice(0,i).join('').split('\n'); let ll=to(i), l=ll.length-1, j=ll[l].length, m=to()[l]; let k=1,o=i-j,cl=j; while (kt?'^':' ').join('')].join('\n'); - if (kt?'^':' ').join('')]; + loc = add.concat(k