Recently Written · git

clic

MIRROR ONLY Gopher client with pretty colours in Common Lisp

git clone https://github.com/equwal/clic

Log | Files | Refs


3rdparties/software/flexi-streams-20200427-git/conditions.lisp (4735 bytes)

1 ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: FLEXI-STREAMS; Base: 10 -*-
2 ;;; $Header: /usr/local/cvsrep/flexi-streams/conditions.lisp,v 1.9 2008/05/25 22:23:58 edi Exp $
3 
4 ;;; Copyright (c) 2005-2008, Dr. Edmund Weitz.  All rights reserved.
5 
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
8 ;;; are met:
9 
10 ;;;   * Redistributions of source code must retain the above copyright
11 ;;;     notice, this list of conditions and the following disclaimer.
12 
13 ;;;   * Redistributions in binary form must reproduce the above
14 ;;;     copyright notice, this list of conditions and the following
15 ;;;     disclaimer in the documentation and/or other materials
16 ;;;     provided with the distribution.
17 
18 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 (in-package :flexi-streams)
31 
32 (define-condition flexi-stream-error (stream-error)
33   ()
34   (:documentation "Superclass for all errors related to flexi
35 streams."))
36 
37 (define-condition flexi-stream-simple-error (flexi-stream-error simple-condition)
38   ()
39   (:documentation "Like FLEXI-STREAM-ERROR but with formatting
40 capabilities."))
41 
42 (define-condition flexi-stream-element-type-error (flexi-stream-error)
43   ((element-type :initarg :element-type
44                  :reader flexi-stream-element-type-error-element-type))
45   (:report (lambda (condition stream)
46              (format stream "Element type ~S not allowed."
47                      (flexi-stream-element-type-error-element-type condition))))
48   (:documentation "Errors of this type are signalled if the flexi
49 stream has a wrong element type."))
50 
51 (define-condition flexi-stream-out-of-sync-error (flexi-stream-error)
52   ()
53   (:report (lambda (condition stream)
54              (declare (ignore condition))
55              (format stream "Stream out of sync from previous
56 lookahead, couldn't rewind.")))
57   (:documentation "This can happen if you're trying to write to an IO
58 stream which had prior to that `looked ahead' while reading and now
59 can't `rewind' to the octet where you /should/ be."))
60 
61 (define-condition in-memory-stream-error (stream-error)
62   ()
63   (:documentation "Superclass for all errors related to
64 IN-MEMORY streams."))
65 
66 (define-condition in-memory-stream-simple-error (in-memory-stream-error simple-condition)
67   ()
68   (:documentation "Like IN-MEMORY-STREAM-ERROR but with formatting
69 capabilities."))
70 
71 (define-condition in-memory-stream-closed-error (in-memory-stream-error)
72   ()
73   (:report (lambda (condition stream)
74              (format stream "~S is closed."
75                      (stream-error-stream condition))))
76   (:documentation "An error that is signalled when someone is trying
77 to read from or write to a closed IN-MEMORY stream."))
78 
79 (define-condition in-memory-stream-position-spec-error (in-memory-stream-simple-error)
80   ((position-spec :initarg :position-spec
81                   :reader in-memory-stream-position-spec-error-position-spec))
82   (:documentation "Errors of this type are signalled if an erroneous
83 position spec is used in conjunction with FILE-POSITION."))
84 
85 (define-condition external-format-condition (simple-condition)
86   ((external-format :initarg :external-format
87                     :initform nil
88                     :reader external-format-condition-external-format))
89   (:documentation "Superclass for all conditions related to external
90 formats."))
91 
92 (define-condition external-format-error (external-format-condition error)
93   ()
94   (:documentation "Superclass for all errors related to external
95 formats."))
96   
97 (define-condition external-format-encoding-error (external-format-error)
98   ()
99   (:documentation "Errors of this type are signalled if there is an
100 encoding problem."))
101 
102 (defun signal-encoding-error (external-format format-control &rest format-args)
103   "Convenience function similar to ERROR to signal conditions of type
104 EXTERNAL-FORMAT-ENCODING-ERROR."
105   (error 'external-format-encoding-error
106          :format-control format-control
107          :format-arguments format-args
108          :external-format external-format))