From d07d687eb3cb0c9a34bb39bd78c13a89960b840f Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 14 Oct 2010 04:42:21 +0000 Subject: [PATCH] Make the debugger robust to errors while printing. --- src/runtime/dbgutl.scm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/runtime/dbgutl.scm b/src/runtime/dbgutl.scm index 366c2630b..e1473694d 100644 --- a/src/runtime/dbgutl.scm +++ b/src/runtime/dbgutl.scm @@ -74,12 +74,23 @@ USA. (if (undefined-value? value) (debugger-message port "No value") (debugger-message port "Value: " value)))) - + (define (output-to-string length thunk) - (let ((x (with-output-to-truncated-string length thunk))) - (if (and (car x) (> length 4)) - (substring-move! " ..." 0 4 (cdr x) (- length 4))) - (cdr x))) + (let ((thunk + (lambda () + (call-with-current-continuation + (lambda (exit) + (bind-condition-handler (list condition-type:error) + (lambda (condition) + (write-string "") + (exit unspecific)) + thunk)))))) + (let ((x (with-output-to-truncated-string length thunk))) + (if (and (car x) (> length 4)) + (substring-move! " ..." 0 4 (cdr x) (- length 4))) + (cdr x)))) (define (show-frames environment depth port) (debugger-presentation port -- 2.25.1