conditions.lisp 2.15 KB
Newer Older
1 2
(in-package :netfarm)

3 4 5
(define-condition parser-error (error)
  ((name :initarg :name
         :reader parser-error-name))
6
  (:report (lambda (condition stream)
7 8
             (format stream "~s could not be parsed"
                     (parser-error-name condition)))))
9

10 11 12 13 14
(define-condition parser-bad-segment-count (parser-error)
  ((count :initarg :count :reader parser-error-segment-count))
  (:report (lambda (condition stream)
             (format stream "~a segment~:p ~:*~[were~;was~;were~] provided, not 3 or 4"
                     (parser-error-segment-count condition)))))
15

16 17
(define-condition parser-empty-line (parser-error)
  ((key :initarg :key :reader parser-error-key))
18
  (:report (lambda (condition stream)
19 20
             (format stream "The key ~a was provided with no values"
                     (render-atom (parser-error-key condition))))))
21

22 23
(define-condition parser-bad-signature (parser-error)
  ((signature :initarg :signature :reader parser-bad-signature-signature))
24
  (:report (lambda (condition stream)
25 26
             (format stream "The signature given is invalid: ~s"
                     (parser-bad-signature-signature condition)))))
27

28 29
(define-condition parser-codecs-in-key (parser-error)
  ((atom :initarg :atom :reader parser-error-key))
30
  (:report (lambda (condition stream)
31 32
             (format stream "A codec was encountered in a slot name: ~s"
                     (parser-error-key condition)))))
33

34 35 36 37 38 39 40 41 42 43
(define-condition schema-error ()
  ())

(define-condition schema-slot-missing (schema-error)
  ((instance :initarg :instance :reader schema-slot-missing-instance)
   (slot-name :initarg :slot-name :reader schema-slot-missing-slot-name))
  (:report (lambda (condition stream)
             (format stream "The slot ~s is missing in ~s"
                     (render-atom (schema-slot-missing-slot-name condition))
                     (schema-slot-missing-instance condition)))))
44

45 46
(define-condition schema-bad-reader-type (schema-error)
  ((reader-type :initarg :type :reader schema-bad-reader-type-type))
47
  (:report (lambda (condition stream)
48 49
             (format stream "The name ~s is not a reader type"
                     (schema-bad-reader-type-type condition)))))