Integrate conditions into the defsystem
[zpng.git] / conditions.lisp
blobfb47b652de959b5b19f11a835e03654610c1505a
1 ;;;
2 ;;; Copyright (c) 2008 Zachary Beane, All Rights Reserved
3 ;;;
4 ;;; Redistribution and use in source and binary forms, with or without
5 ;;; modification, are permitted provided that the following conditions
6 ;;; are met:
7 ;;;
8 ;;; * Redistributions of source code must retain the above copyright
9 ;;; notice, this list of conditions and the following disclaimer.
10 ;;;
11 ;;; * Redistributions in binary form must reproduce the above
12 ;;; copyright notice, this list of conditions and the following
13 ;;; disclaimer in the documentation and/or other materials
14 ;;; provided with the distribution.
15 ;;;
16 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
17 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 ;;;
28 ;;; conditions.lisp
30 (in-package #:zpng)
32 (define-condition zpng-error (error) ())
34 (define-condition invalid-size (zpng-error)
35 ((width
36 :initarg :width
37 :reader invalid-size-width)
38 (height
39 :initarg :height
40 :reader invalid-size-height))
41 (:report (lambda (condition stream)
42 (format stream "Invalid PNG size ~Ax~A; ~
43 both width and height must be positive"
44 (invalid-size-width condition)
45 (invalid-size-height condition)))))
47 (define-condition invalid-row-length (zpng-error)
48 ((expected-length
49 :initarg :expected-length
50 :accessor invalid-row-length-expected-length)
51 (actual-length
52 :initarg :actual-length
53 :accessor invalid-row-length-actual-length))
54 (:report (lambda (condition stream)
55 (format stream "Invalid row length ~A (expected ~A)"
56 (invalid-row-length-actual-length condition)
57 (invalid-row-length-expected-length condition)))))
59 (define-condition insufficient-rows (zpng-error)
60 ((written
61 :initarg :written
62 :accessor insufficient-rows-written)
63 (needed
64 :initarg :needed
65 :accessor insufficient-rows-needed))
66 (:report (lambda (condition stream)
67 (format stream "Insufficient rows written; need ~A, but only ~A ~
68 written"
69 (insufficient-rows-needed condition)
70 (insufficient-rows-written condition)))))
72 (define-condition too-many-rows (zpng-error)
73 ((count
74 :initarg :count
75 :accessor too-many-rows-count))
76 (:report (lambda (condition stream)
77 (format stream "Too many rows written for PNG; maximum row count ~
78 is ~A"
79 (too-many-rows-count condition)))))