mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Provide a hook for the exception printer
This commit is contained in:
parent
bb7154fb80
commit
ed5e37caa0
1 changed files with 9 additions and 6 deletions
|
@ -329,6 +329,7 @@ If returning early, return the return value of F."
|
||||||
;; let format alias simple-format until the more complete version is loaded
|
;; let format alias simple-format until the more complete version is loaded
|
||||||
|
|
||||||
(define format simple-format)
|
(define format simple-format)
|
||||||
|
(define exception-format simple-format)
|
||||||
|
|
||||||
;; this is scheme wrapping the C code so the final pred call is a tail call,
|
;; this is scheme wrapping the C code so the final pred call is a tail call,
|
||||||
;; per SRFI-13 spec
|
;; per SRFI-13 spec
|
||||||
|
@ -1895,7 +1896,7 @@ non-locally, that exit determines the continuation."
|
||||||
(set! print-exception
|
(set! print-exception
|
||||||
(lambda (port frame key args)
|
(lambda (port frame key args)
|
||||||
(define (default-printer)
|
(define (default-printer)
|
||||||
(format port "Throw to key `~a' with args `~s'." key args))
|
(exception-format port "Throw to key `~a' with args `~s'." key args))
|
||||||
|
|
||||||
(when frame
|
(when frame
|
||||||
(print-location frame port)
|
(print-location frame port)
|
||||||
|
@ -1913,7 +1914,9 @@ non-locally, that exit determines the continuation."
|
||||||
(printer port key args default-printer)
|
(printer port key args default-printer)
|
||||||
(default-printer))))
|
(default-printer))))
|
||||||
(lambda (k . args)
|
(lambda (k . args)
|
||||||
(format port "Error while printing exception.")))
|
(exception-format
|
||||||
|
port "Error while printing exception `~a`: `~a' with args [~s]"
|
||||||
|
key k args)))
|
||||||
(newline port)
|
(newline port)
|
||||||
(force-output port))))
|
(force-output port))))
|
||||||
|
|
||||||
|
@ -1928,7 +1931,7 @@ non-locally, that exit determines the continuation."
|
||||||
((subr msg args . rest)
|
((subr msg args . rest)
|
||||||
(if subr
|
(if subr
|
||||||
(format port "In procedure ~a: " subr))
|
(format port "In procedure ~a: " subr))
|
||||||
(apply format port msg (or args '())))
|
(apply exception-format port msg (or args '())))
|
||||||
(_ (default-printer)))
|
(_ (default-printer)))
|
||||||
args))
|
args))
|
||||||
|
|
||||||
|
@ -1955,7 +1958,7 @@ non-locally, that exit determines the continuation."
|
||||||
(define (keyword-error-printer port key args default-printer)
|
(define (keyword-error-printer port key args default-printer)
|
||||||
(let ((message (cadr args))
|
(let ((message (cadr args))
|
||||||
(faulty (car (cadddr args)))) ; I won't do it again, I promise.
|
(faulty (car (cadddr args)))) ; I won't do it again, I promise.
|
||||||
(format port "~a: ~s" message faulty)))
|
(exception-format port "~a: ~s" message faulty)))
|
||||||
|
|
||||||
(define (getaddrinfo-error-printer port key args default-printer)
|
(define (getaddrinfo-error-printer port key args default-printer)
|
||||||
(format port "In procedure getaddrinfo: ~a" (gai-strerror (car args))))
|
(format port "In procedure getaddrinfo: ~a" (gai-strerror (car args))))
|
||||||
|
@ -2172,11 +2175,11 @@ non-locally, that exit determines the continuation."
|
||||||
(lambda (key . args)
|
(lambda (key . args)
|
||||||
(for-each (lambda (s)
|
(for-each (lambda (s)
|
||||||
(if (not (string-null? s))
|
(if (not (string-null? s))
|
||||||
(format (current-warning-port) ";;; ~a\n" s)))
|
(exception-format (current-warning-port) ";;; ~a\n" s)))
|
||||||
(string-split
|
(string-split
|
||||||
(call-with-output-string
|
(call-with-output-string
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(format port template arg ...)
|
(exception-format port template arg ...)
|
||||||
(print-exception port #f key args)))
|
(print-exception port #f key args)))
|
||||||
#\newline))
|
#\newline))
|
||||||
#f)))))
|
#f)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue