io: format
error message fixes.
This commit is contained in:
parent
0af11de62b
commit
7f44aaf2bf
|
@ -153,12 +153,23 @@
|
|||
(with-handlers ([exn:fail? exn-message])
|
||||
(error 'no "hi ~s" 10)))
|
||||
|
||||
(test "error: format string requires 1 arguments, given 3"
|
||||
(test "error: format string requires 1 arguments, given 3; arguments were: 1 2 3"
|
||||
(with-handlers ([exn:fail? exn-message])
|
||||
(error 'no "hi ~s" 1 2 3)))
|
||||
(test "error: format string requires 2 arguments, given 1"
|
||||
(test "error: format string requires 2 arguments, given 1; arguments were: 8"
|
||||
(with-handlers ([exn:fail? exn-message])
|
||||
(error 'no "hi ~s ~s" 8)))
|
||||
(test "error: format string requires 2 arguments, given 100"
|
||||
(with-handlers ([exn:fail? exn-message])
|
||||
(apply error 'no "hi ~s ~s" (for/list ([i 100]) i))))
|
||||
(test "error: format string requires 2 arguments, given 51"
|
||||
(with-handlers ([exn:fail? exn-message])
|
||||
(apply error 'no "hi ~s ~s" (for/list ([i 51]) i))))
|
||||
(test (apply string-append
|
||||
"error: format string requires 2 arguments, given 50; arguments were:"
|
||||
(for/list ([i 50]) (string-append " " (number->string i))))
|
||||
(with-handlers ([exn:fail? exn-message])
|
||||
(apply error 'no "hi ~s ~s" (for/list ([i 50]) i))))
|
||||
|
||||
(define infinite-ones
|
||||
(make-input-port 'ones
|
||||
|
|
|
@ -195,5 +195,16 @@
|
|||
(define (value->string v)
|
||||
((error-value->string-handler) v (error-print-width)))
|
||||
|
||||
(define (arguments->string args)
|
||||
"")
|
||||
(define (arguments->string fmt+args)
|
||||
(define args (cdr fmt+args))
|
||||
(if (or (null? args) (<= (length args) 50))
|
||||
(parameterize ([error-print-width
|
||||
(max 2 (round (/ (error-print-width) (length args))))])
|
||||
(apply string-append
|
||||
"; "
|
||||
"arguments were: "
|
||||
(let loop ([ss (map value->string args)])
|
||||
(if (or (null? ss) (null? (cdr ss)))
|
||||
ss
|
||||
(cons (car ss) (cons " " (loop (cdr ss))))))))
|
||||
""))
|
||||
|
|
Loading…
Reference in New Issue
Block a user