On this page:

9 Exception utilities

 (require (planet untyped/unlib/exn))
Utilities for raising and handling exceptions.

(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.


  > (with-handlers ([exn? pretty-print])
      (raise-exn exn:fail "Oops!"))




  > (with-handlers ([exn? pretty-print])
      (raise-exn exn:fail:syntax "Oops!" (list #'a #'b #'c)))







(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.


  > (with-handlers ([exn? pretty-print])
      (with-handlers ([exn? (lambda (e)
                              (reraise-exn e exn:fail
                                "Looks serious"))])
        (raise-exn exn "Oops!")))


    "Looks serious: Oops!"