Next: , Previous: , Up: platform   [Index]


3.4 More features for errno

One syntax identifier binding for each known errno value is exported by the library (vicare platform errno) and reexported by the library (vicare platform constants); (vicare-scheme)Interface to errno for details on Vicare internal encoding of errno codes. The following bindings are exported by the library (vicare platform errno).

Syntax: errno-code ?symbol

Verify that ?symbol is one of the symbolic names of errno; if successful expand to an expression evaluating to the coded errno value, else raise a syntax violation.

Syntax: case-errno ?errno ((?code0 ?code ...) . ?cbody) ...
Syntax: case-errno ?errno ((?code0 ?code ...) . ?cbody) ... (else . ?ebody)
Auxiliary Syntax: else

Specialised case macro for errno values. else is the auxiliary keyword exported by (rnrs). Example:

#!r6rs
(import (rnrs)
  (vicare platform errno))

(define identifier "some-port")

(case-errno (errno)
  ((EACCES EFAULT)
   (make-i/o-file-protection-error identifier))
  ((EROFS)
   (make-i/o-file-is-read-only-error identifier))
  ((EEXIST)
   (make-i/o-file-already-exists-error identifier))
  ((EIO)
   (make-i/o-error))
  ((ENOENT)
   (make-i/o-file-does-not-exist-error identifier))
  (else
   (make-irritants-condition (list identifier))))

The ?code must be symbols representing errno codes, they are not meant to be binding identifiers.