custom-exceptions.scm 762 B

1234567891011121314151617181920212223
  1. (library (custom-exceptions)
  2. (export make-lookup-error)
  3. (import (except (rnrs base) error)
  4. (only (guile)
  5. lambda* λ
  6. record-constructor)
  7. (ice-9 exceptions))
  8. (define make-lookup-error
  9. ;; record-constructor is a procedure, which will return the
  10. ;; constructor for any record.
  11. (record-constructor
  12. ;; Create an exception type, which is a record. This record has a
  13. ;; constructor, which we can name using define for example.
  14. (make-exception-type
  15. ;; name of the new exception type
  16. '&lookup-error
  17. ;; parent exception type
  18. &programming-error
  19. ;; list of values the constructor of the exception takes and their
  20. ;; names in the record
  21. '(key)))))