From 0f2664cdd9ec565b0b59ef3d89054c69f020336c Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 27 May 2012 11:29:21 -0600 Subject: [PATCH] more error-message conversions and repairs original commit: a137459b65b54d65595e854101aae7440d9e65f6 --- collects/mzlib/etc.rkt | 2 +- collects/mzlib/port.rkt | 10 +++++----- collects/mzlib/pregexp.rkt | 2 +- collects/mzlib/process.rkt | 19 +++++++++++++------ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/collects/mzlib/etc.rkt b/collects/mzlib/etc.rkt index f46d907..37c04f6 100644 --- a/collects/mzlib/etc.rkt +++ b/collects/mzlib/etc.rkt @@ -236,7 +236,7 @@ (define (namespace-defined? n) (unless (symbol? n) - (raise-type-error 'namespace-defined? "symbol" n)) + (raise-argument-error 'namespace-defined? "symbol?" n)) (not (eq? (namespace-variable-value n #t (lambda () ns-undefined)) ns-undefined))) diff --git a/collects/mzlib/port.rkt b/collects/mzlib/port.rkt index 81ce65d..e373aaf 100644 --- a/collects/mzlib/port.rkt +++ b/collects/mzlib/port.rkt @@ -34,12 +34,12 @@ [(a b) (merge-input a b 4096)] [(a b limit) (or (input-port? a) - (raise-type-error 'merge-input "input-port" a)) + (raise-argument-error 'merge-input "input-port?" a)) (or (input-port? b) - (raise-type-error 'merge-input "input-port" b)) + (raise-argument-error 'merge-input "input-port?" b)) (or (not limit) (and (number? limit) (positive? limit) (exact? limit) (integer? limit)) - (raise-type-error 'merge-input "positive exact integer or #f" limit)) + (raise-argument-error 'merge-input "(or/c exact-positive-integer #f)" limit)) (let-values ([(rd wt) (make-pipe-with-specials limit)] [(other-done?) #f] [(sema) (make-semaphore 1)]) @@ -898,10 +898,10 @@ (define special-filter-input-port (lambda (p filter [close? #t]) (unless (input-port? p) - (raise-type-error 'special-filter-input-port "input port" p)) + (raise-argument-error 'special-filter-input-port "input-port?" p)) (unless (and (procedure? filter) (procedure-arity-includes? filter 2)) - (raise-type-error 'special-filter-input-port "procedure (arity 2)" filter)) + (raise-argument-error 'special-filter-input-port "(any/c bytes? . -> . any/c)" filter)) (make-input-port (object-name p) (lambda (s) diff --git a/collects/mzlib/pregexp.rkt b/collects/mzlib/pregexp.rkt index f1773be..25dae13 100644 --- a/collects/mzlib/pregexp.rkt +++ b/collects/mzlib/pregexp.rkt @@ -23,7 +23,7 @@ [(string? pattern) (pregexp pattern)] [(regexp? pattern) pattern] [(byte-regexp? pattern) pattern] - [else (raise-type-error who "regexp, byte-regexp, string, or byte string" + [else (raise-argument-error who "(or/c regexp? byte-regexp? string? bytes?)" pattern)])) (define/kw (pregexp-match pattern input #:optional [start-k 0] [end-k #f] [output-port #f]) diff --git a/collects/mzlib/process.rkt b/collects/mzlib/process.rkt index 693c01b..49f5562 100644 --- a/collects/mzlib/process.rkt +++ b/collects/mzlib/process.rkt @@ -35,7 +35,7 @@ (define (check-exe who exe) (unless (path-string? exe) - (raise-type-error who "path or string" exe)) + (raise-argument-error who "path-string?" exe)) exe) (define (path-or-ok-string? s) @@ -75,14 +75,21 @@ (for ([s (in-list args)]) (unless (or (path-or-ok-string? s) (bytes-no-nuls? s)) - (raise-type-error who "path, string, or byte string (without nuls)" - s)))]) + (raise-argument-error + who + (string-append "(or/c path-string?\n" + " (and/c bytes? (lambda (bs) (not (memv 0 (bytes->list bs))))))") + s)))]) args) (define (check-command who str) (unless (or (string-no-nuls? str) (bytes-no-nuls? str)) - (raise-type-error who "string or byte string (without nuls)" str))) + (raise-argument-error + who + (string-append "(or/c (and/c string? (lambda (s) (not (memv #\\nul (string->list s)))))\n" + " (and/c bytes? (lambda (bs) (not (memv 0 (bytes->list bs))))))") + str))) ;; Old-style functions: ---------------------------------------- @@ -131,9 +138,9 @@ (twait se))] [(interrupt) (subprocess-kill subp #f)] [(kill) (subprocess-kill subp #t)] - [else (raise-type-error + [else (raise-argument-error 'control-process - "'status, 'exit-code, 'wait, 'interrupt, or 'kill" m)])) + "(or/c 'status 'exit-code 'wait 'interrupt 'kill)" m)])) (list (aport so) (aport si) (subprocess-pid subp)