On this page:
raise-misc-error
compose-error-message
5.3.6

8 Errors

Ryan Culpepper <ryanc@racket-lang.org>

This library is unstable; compatibility will not be maintained. See Unstable: May Change Without Warning for more information.

 (require unstable/error)

procedure

(raise-misc-error name    
  message    
  field    
  value ...    
  ...    
  [#:continued continued-message    
  #:constructor constructor])  any
  name : symbol?
  message : string?
  field : 
(let ([option/c (or/c 'value 'multi 'maybe)])
  (or/c string? (cons/c string? (listof option/c))))
  value : any/c
  continued-message : (or/c string? (listof string?)) = null
  constructor : (-> string? continuation-mark-set? exn?)
   = exn:fail
Raises an exception with a message composed according to the Racket error message convention. The exception is created with constructor, which is exn:fail by default.

The composed error message includes details consisting of the alternating field and value arguments. By default, value is formatted as if by display unless it is #f, in which case the detail line is omitted. The following options affect the formatting of the detail line:

Examples:

> (raise-misc-error 'mcbean "too many stars upon thars"
                    '("given" value) 'star-bellied-sneetch
                    '("stars" value) 3)

mcbean: too many stars upon thars

  given: 'star-bellied-sneetch

  stars: 3

> (raise-misc-error 'hal "unable to open pod bay doors"
                    #:continued
                    "this mission is too important to let you jeopardize it"
                    "threat" "David Bowman"
                    "detection" "lip reading")

hal: unable to open pod bay doors;

 this mission is too important to let you jeopardize it

  threat: David Bowman

  detection: lip reading

> (raise-misc-error 'car "missing car keys"
                    '("searched" multi)
                    (list "dresser" "desk" "kitchen table" "under sofa"
                          "behind microwave" "in washing machine")
                    "last seen"
                    #f)

car: missing car keys

  searched:

   dresser

   desk

   kitchen table

   under sofa

   behind microwave

   in washing machine

procedure

(compose-error-message name    
  message    
  field    
  value ...    
  ...    
  [#:continued continued-message])  string?
  name : symbol?
  message : string?
  field : 
(let ([option/c (or/c 'value 'multi 'maybe)])
  (or/c string? (cons/c string? (listof option/c))))
  value : any/c
  continued-message : (or/c string? (listof string?)) = null
Like raise-misc-error, but produces a string conforming to the Racket error message convention.