File: conditions.lisp

package info (click to toggle)
cl-containers 20150923-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,076 kB
  • sloc: lisp: 8,341; makefile: 14
file content (36 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(in-package #:cl-containers)

(defcondition container-condition () 
    ((container :initarg :container :reader container)))

(defcondition container-error (container-condition error)
  ()
  (:export-p t)
  (:export-slots-p t))

(defcondition index-out-of-range-error (container-error)
  ((index 0 ir))
  (:report (lambda (c s)
             (if (< (index c) 0)
               (format s "Index ~D is negative, it must be between 0 and the size of the container."
                       (index c))
               (format s "Index ~D out of range for container ~A, size is only ~D."
                       (index c) (class-name (class-of (container c))) (size (container c)))))))

(define-condition key-does-not-exist-error (container-error)
  ())

(define-condition queue-empty (container-error)
                  ((message :initarg :message
                            :reader message))
  (:report (lambda (c stream)
             (format stream "~A" (message c)))))

(define-condition record-not-found-error (container-error)
                  ((table :initarg :table :accessor table)
                   (value :initarg :value :accessor value)))

(defcondition element-not-found-error (container-error)
    ((element :initarg :element :reader element))
    (:export-p t)
  (:export-slots-p element))