1 Exception utilities
2 Number utilities
3 String utilities
4 Bytes utilities
5 Symbol utilities
6 List utilities
7 PLT 4x hash utilities
8 PLT 3x hash utilities
9 URL utilities
10 Contract utilities
11 File and path utilities
12 Parameter utilities
13 Syntax utilities
14 SRFI19 time utilities
15 Scribble utilities
16 Generators
17 Generators (short names)
18 Pipelines
19 Write-through cache
20 Yieldable procedures
21 Debugging tools
22 Profiling tools
23 Logging tools
On this page:
display-exn
raise-exn
reraise-exn
Version: 4.0.1.2

 

1 Exception utilities

 (require (planet untyped/unlib/exn))

Utilities for raising, handling and printing exceptions.

(display-exn exn)  void?

  exn : exn?

Prints the message and stack trace of exn to the current output port. Re-provided from "text-ui.ss" in SchemeUnit.

Examples:

  > (with-handlers ([exn? display-exn])

      (error "Oops!"))

  Oops!

  

   === context ===

  /usr/local/plt/collects/scheme/sandbox.ss:466:4: loop

  

  

(raise-exn id message arg ...)

Raises an exception with a default set of continuation marks. id is the identifier of the exception’s structure type transformer binding (e.g. exn or exn:fail). message and args are passed to the exception’s constructor, along with the value of current-continuation-marks.

Examples:

  > (with-handlers ([exn? pretty-print])

      (raise-exn exn:fail "Oops!"))

  #(struct:exn:fail

    "Oops!"

    #<continuation-mark-set>)

  > (with-handlers ([exn? pretty-print])

      (raise-exn exn:fail:syntax "Oops!" (list #'a #'b #'c)))

  #(struct:exn:fail:syntax

    "Oops!"

    #<continuation-mark-set>

    (#<syntax:8:0>

     #<syntax:8:0>

     #<syntax:8:0>))

(reraise-exn old-exn new-exn new-message arg ...)

Raises new-exn with a message of:

  (string-append (exn-message old-exn) ": " new-message)

and the same continuation marks as old-exn. Any additional args are passed to the constructor of new-exn.

Examples:

  > (with-handlers ([exn? pretty-print])

      (with-handlers ([exn? (lambda (e)

                              (reraise-exn e exn:fail

                                "Looks serious"))])

        (raise-exn exn "Oops!")))

  #(struct:exn:fail

    "Looks serious: Oops!"

    #<continuation-mark-set>)