Tweak display of stack traces
Tweak the frames to display and try to harden the code to crash less.
This commit is contained in:
parent
123c920122
commit
78d22d1acc
1 changed files with 26 additions and 8 deletions
34
knots.scm
34
knots.scm
|
@ -75,6 +75,8 @@
|
||||||
0 (and prompt-tag 1)))
|
0 (and prompt-tag 1)))
|
||||||
(_
|
(_
|
||||||
(make-stack #t))))
|
(make-stack #t))))
|
||||||
|
(stack-len
|
||||||
|
(stack-length stack))
|
||||||
(error-string
|
(error-string
|
||||||
(call-with-output-string
|
(call-with-output-string
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
|
@ -83,30 +85,46 @@
|
||||||
(filter knots-exception?
|
(filter knots-exception?
|
||||||
(simple-exceptions exn)))))
|
(simple-exceptions exn)))))
|
||||||
|
|
||||||
(let ((stack-vec
|
(let* ((stack-vec
|
||||||
(stack->vector stack)))
|
(stack->vector stack))
|
||||||
|
(stack-vec-length
|
||||||
|
(vector-length stack-vec)))
|
||||||
(print-frames (list->vector
|
(print-frames (list->vector
|
||||||
(drop
|
(drop
|
||||||
(vector->list stack-vec)
|
(vector->list stack-vec)
|
||||||
6))
|
(if (< stack-vec-length 5)
|
||||||
|
0
|
||||||
|
4)))
|
||||||
port
|
port
|
||||||
#:count (stack-length stack)))
|
#:count (stack-length stack)))
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (stack)
|
(lambda (stack)
|
||||||
(let ((stack-vec
|
(let* ((stack-vec
|
||||||
(stack->vector stack)))
|
(stack->vector stack))
|
||||||
|
(stack-vec-length
|
||||||
|
(vector-length stack-vec)))
|
||||||
(print-frames (list->vector
|
(print-frames (list->vector
|
||||||
(drop
|
(drop
|
||||||
(vector->list stack-vec)
|
(vector->list stack-vec)
|
||||||
3))
|
(if (< stack-vec-length 4)
|
||||||
|
0
|
||||||
|
3)))
|
||||||
port
|
port
|
||||||
#:count (stack-length stack))))
|
#:count (stack-length stack))))
|
||||||
knots-stacks)
|
knots-stacks)
|
||||||
(print-exception
|
(print-exception
|
||||||
port
|
port
|
||||||
(if (null? knots-stacks)
|
(if (null? knots-stacks)
|
||||||
(stack-ref stack 1)
|
(stack-ref stack
|
||||||
(stack-ref (last knots-stacks) 3))
|
(if (< stack-len 4)
|
||||||
|
stack-len
|
||||||
|
4))
|
||||||
|
(let* ((stack (last knots-stacks))
|
||||||
|
(stack-len (stack-length stack)))
|
||||||
|
(stack-ref stack
|
||||||
|
(if (< stack-len 3)
|
||||||
|
stack-len
|
||||||
|
3))))
|
||||||
'%exception
|
'%exception
|
||||||
(list exn)))))))
|
(list exn)))))))
|
||||||
(display error-string port)))
|
(display error-string port)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue