Add exn->string, following the function of the same name in the web-server.
This commit is contained in:
parent
502575b641
commit
4b2c9cfbcc
|
@ -960,3 +960,15 @@ property, @racket[#f] otherwise.}
|
|||
(exn:missing-module? . -> . module-path?)]{
|
||||
|
||||
Returns the @tech{module path}-getting procedure associated with @racket[v].}
|
||||
|
||||
@;------------------------------------------------------------------------
|
||||
@section{Additional Exception Functions}
|
||||
|
||||
@note-lib-only[racket/exn]
|
||||
|
||||
@defproc[(exn->string [exn (or/c exn? any/c)]) string?]{
|
||||
|
||||
Formats @racket[exn] as a string. If @racket[exn] is an @racket[exn?],
|
||||
collects and returns the output from the current
|
||||
@racket[(error-display-handler)]; otherwise, simply converts
|
||||
@racket[exn] to a string using @racket[(format "~s\n" exn)].}
|
||||
|
|
10
racket/collects/racket/exn.rkt
Normal file
10
racket/collects/racket/exn.rkt
Normal file
|
@ -0,0 +1,10 @@
|
|||
#lang racket/base
|
||||
|
||||
(provide exn->string)
|
||||
|
||||
(define (exn->string exn)
|
||||
(if (exn? exn)
|
||||
(parameterize ([current-error-port (open-output-string)])
|
||||
((error-display-handler) (exn-message exn) exn)
|
||||
(get-output-string (current-error-port)))
|
||||
(format "~s\n" exn)))
|
Loading…
Reference in New Issue
Block a user