▼ |  | Unstable: May Change Without Warning

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

On this page:

raise-misc-error
compose-error-message

5.3.6
top ← prev up next →

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

- '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 →