2 ;;; Copyright (c) 2008 Zachary Beane, All Rights Reserved
4 ;;; Redistribution and use in source and binary forms, with or without
5 ;;; modification, are permitted provided that the following conditions
8 ;;; * Redistributions of source code must retain the above copyright
9 ;;; notice, this list of conditions and the following disclaimer.
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.
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.
32 (define-condition zpng-error
(error) ())
34 (define-condition invalid-size
(zpng-error)
37 :reader invalid-size-width
)
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)
49 :initarg
:expected-length
50 :accessor invalid-row-length-expected-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)
62 :accessor insufficient-rows-written
)
65 :accessor insufficient-rows-needed
))
66 (:report
(lambda (condition stream
)
67 (format stream
"Insufficient rows written; need ~A, but only ~A ~
69 (insufficient-rows-needed condition
)
70 (insufficient-rows-written condition
)))))
72 (define-condition incomplete-row
(zpng-error)
75 :accessor incomplete-row-written
)
78 :accessor incomplete-row-needed
))
79 (:report
(lambda (condition stream
)
80 (format stream
"Incomplete row started; need ~A, but only ~A ~
82 (incomplete-row-needed condition
)
83 (incomplete-row-written condition
)))))
85 (define-condition too-many-rows
(zpng-error)
88 :accessor too-many-rows-count
))
89 (:report
(lambda (condition stream
)
90 (format stream
"Too many rows written for PNG; maximum row count ~
92 (too-many-rows-count condition
)))))
94 (define-condition color-type-mismatch
(zpng-error)
97 :accessor color-type-mismatch-given
)
100 :accessor color-type-mismatch-expected
))
101 (:report
(lambda (condition stream
)
102 (format stream
"Wrong number of samples for PNG pixel; need ~A, ~
104 (color-type-mismatch-expected condition
)
105 (color-type-mismatch-given condition
)))))