▼ |  | Unstable: May Change Without Warning

1 | Guidelines for Developing unstable Libraries
2 | Automata: Compiling State Machines
3 | Bytes
4 | Contracts
5 | Converting Values to Strings
6 | Contracts for Macro Subexpressions
7 | Debugging
8 | Definitions
9 | Errors
10 | Filesystem
11 | Find
12 | Flonums
13 | Futures
14 | Functions
15 | Hash Tables
16 | Interface-Oriented Programming for Classes
17 | Lazy Require
18 | Lists
19 | Logging
20 | Mark Parameters
21 | Match
22 | Open place expressions
23 | Parameter Groups
24 | Pretty-Printing
25 | Re-Contracting Identifiers
26 | Sandbox
27 | Sequences
28 | Strings
29 | Structs
30 | Struct Printing
31 | Syntax
32 | Temporal Contracts: Explicit Contract Monitors
33 | GUI Libraries

On this page:

raise-misc-error
compose-error-message

Version: 5.3.1
top ← prev up next →

### 9`` 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:

- 'multi formats each element in the corresponding value, which must be a list, as a separate line

- 'value formats the value using error-value->string-handler; the detail line is not omittable unless 'maybe or 'multi is also provided

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.
top ← prev up next →