1 ;;;; stuff originally from CMU CL's error.lisp which can or should
2 ;;;; come late (mostly related to the CONDITION class itself)
4 ;;;; FIXME: should perhaps be called condition.lisp, or moved into
7 ;;;; This software is part of the SBCL system. See the README file for
10 ;;;; This software is derived from the CMU CL system, which was
11 ;;;; written at Carnegie Mellon University and released into the
12 ;;;; public domain. The software is in the public domain and is
13 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
14 ;;;; files for more information.
16 (in-package "SB!KERNEL")
18 ;;;; the CONDITION class
20 (/show0 "late-target-error.lisp 20")
22 (eval-when (:compile-toplevel :load-toplevel :execute)
24 (def!struct (condition-class (:include slot-class)
25 (:constructor bare-make-condition-class))
26 ;; list of CONDITION-SLOT structures for the direct slots of this
28 (slots nil :type list)
29 ;; list of CONDITION-SLOT structures for all of the effective class
30 ;; slots of this class
31 (class-slots nil :type list)
32 ;; report function or NIL
33 (report nil :type (or function null))
34 ;; list of alternating initargs and initforms
35 (default-initargs () :type list)
36 ;; class precedence list as a list of class objects, with all
37 ;; non-condition classes removed
39 ;; a list of all the effective instance allocation slots of this
40 ;; class that have a non-constant initform or default-initarg.
41 ;; Values for these slots must be computed in the dynamic
42 ;; environment of MAKE-CONDITION.
43 (hairy-slots nil :type list))
45 (defun make-condition-class (&rest rest)
46 (apply #'bare-make-condition-class
47 (rename-key-args '((:name :%name)) rest)))
52 (:constructor make-condition-object (actual-initargs))
53 (:alternate-metaclass instance
57 ;; actual initargs supplied to MAKE-CONDITION
58 (actual-initargs (required-argument) :type list)
59 ;; a plist mapping slot names to any values that were assigned or
60 ;; defaulted after creation
61 (assigned-slots () :type list))
63 (defstruct (condition-slot (:copier nil))
64 (name (required-argument) :type symbol)
65 ;; list of all applicable initargs
66 (initargs (required-argument) :type list)
67 ;; names of reader and writer functions
68 (readers (required-argument) :type list)
69 (writers (required-argument) :type list)
70 ;; true if :INITFORM was specified
71 (initform-p (required-argument) :type (member t nil))
72 ;; If this is a function, call it with no args. Otherwise, it's the
74 (initform (required-argument) :type t)
75 ;; allocation of this slot, or NIL until defaulted
76 (allocation nil :type (member :instance :class nil))
77 ;; If ALLOCATION is :CLASS, this is a cons whose car holds the value.
78 (cell nil :type (or cons null)))
80 (eval-when (#-sb-xc :compile-toplevel :load-toplevel :execute)
81 ;; the appropriate initialization value for the CPL slot of a
82 ;; CONDITION, calculated by looking at the INHERITS information in
83 ;; the LAYOUT of the CONDITION
84 (defun condition-class-cpl-from-layout (condition)
85 (declare (type condition condition))
86 (let* ((class (sb!xc:find-class condition))
87 (layout (class-layout class))
88 (superset (map 'list #'identity (layout-inherits layout))))
89 (delete-if (lambda (superclass)
90 (not (typep superclass 'condition-class)))
93 ;;; KLUDGE: It's not clear to me why CONDITION-CLASS has itself listed
94 ;;; in its CPL, while other classes derived from CONDITION-CLASS don't
95 ;;; have themselves listed in their CPLs. This behavior is inherited
96 ;;; from CMU CL, and didn't seem to be explained there, and I haven't
97 ;;; figured out whether it's right. -- WHN 19990612
98 (eval-when (:compile-toplevel :load-toplevel :execute)
99 (let ((condition-class (locally
100 ;; KLUDGE: There's a FIND-CLASS DEFTRANSFORM for
101 ;; constant class names which creates fast but
102 ;; non-cold-loadable, non-compact code. In this
103 ;; context, we'd rather have compact, cold-loadable
104 ;; code. -- WHN 19990928
105 (declare (notinline sb!xc:find-class))
106 (sb!xc:find-class 'condition))))
107 (setf (condition-class-cpl condition-class)
108 (list condition-class))))
110 (setf (condition-class-report (locally
111 ;; KLUDGE: There's a FIND-CLASS DEFTRANSFORM
112 ;; for constant class names which creates fast
113 ;; but non-cold-loadable, non-compact code. In
114 ;; this context, we'd rather have compact,
115 ;; cold-loadable code. -- WHN 19990928
116 (declare (notinline sb!xc:find-class))
117 (find-class 'condition)))
118 #'(lambda (cond stream)
119 (format stream "Condition ~S was signalled." (type-of cond))))
121 (eval-when (:compile-toplevel :load-toplevel :execute)
123 (defun find-condition-layout (name parent-types)
124 (let* ((cpl (remove-duplicates
127 (mapcar #'(lambda (x)
129 (sb!xc:find-class x)))
131 (cond-layout (info :type :compiler-layout 'condition))
132 (olayout (info :type :compiler-layout name))
134 (concatenate 'simple-vector
135 (layout-inherits cond-layout)
136 (mapcar #'class-layout cpl))))
138 (not (mismatch (layout-inherits olayout) new-inherits)))
140 (make-layout :class (make-undefined-class name)
141 :inherits new-inherits
143 :length (layout-length cond-layout)))))
147 ;;; FIXME: ANSI's definition of DEFINE-CONDITION says
148 ;;; Condition reporting is mediated through the PRINT-OBJECT method
149 ;;; for the condition type in question, with *PRINT-ESCAPE* always
150 ;;; being nil. Specifying (:REPORT REPORT-NAME) in the definition of
151 ;;; a condition type C is equivalent to:
152 ;;; (defmethod print-object ((x c) stream)
153 ;;; (if *print-escape* (call-next-method) (report-name x stream)))
154 ;;; The current code doesn't seem to quite match that.
155 (def!method print-object ((x condition) stream)
157 (print-unreadable-object (x stream :type t :identity t))
158 ;; KLUDGE: A comment from CMU CL here said
159 ;; 7/13/98 BUG? CPL is not sorted and results here depend on order of
160 ;; superclasses in define-condition call!
161 (dolist (class (condition-class-cpl (sb!xc:class-of x))
162 (error "no REPORT? shouldn't happen!"))
163 (let ((report (condition-class-report class)))
165 (return (funcall report x stream)))))))
167 ;;;; slots of CONDITION objects
169 (defvar *empty-condition-slot* '(empty))
171 (defun find-slot-default (class slot)
172 (let ((initargs (condition-slot-initargs slot))
173 (cpl (condition-class-cpl class)))
175 (let ((default-initargs (condition-class-default-initargs class)))
176 (dolist (initarg initargs)
177 (let ((val (getf default-initargs initarg *empty-condition-slot*)))
178 (unless (eq val *empty-condition-slot*)
179 (return-from find-slot-default
184 (if (condition-slot-initform-p slot)
185 (let ((initform (condition-slot-initform slot)))
186 (if (functionp initform)
189 (error "unbound condition slot: ~S" (condition-slot-name slot)))))
191 (defun find-condition-class-slot (condition-class slot-name)
193 (condition-class-cpl condition-class)
194 (error "There is no slot named ~S in ~S."
195 slot-name condition-class))
196 (dolist (slot (condition-class-slots sclass))
197 (when (eq (condition-slot-name slot) slot-name)
198 (return-from find-condition-class-slot slot)))))
200 (defun condition-writer-function (condition new-value name)
201 (dolist (cslot (condition-class-class-slots
202 (layout-class (%instance-layout condition)))
203 (setf (getf (condition-assigned-slots condition) name)
205 (when (eq (condition-slot-name cslot) name)
206 (return (setf (car (condition-slot-cell cslot)) new-value)))))
208 (defun condition-reader-function (condition name)
209 (let ((class (layout-class (%instance-layout condition))))
210 (dolist (cslot (condition-class-class-slots class))
211 (when (eq (condition-slot-name cslot) name)
212 (return-from condition-reader-function
213 (car (condition-slot-cell cslot)))))
215 (let ((val (getf (condition-assigned-slots condition) name
216 *empty-condition-slot*)))
217 (if (eq val *empty-condition-slot*)
218 (let ((actual-initargs (condition-actual-initargs condition))
219 (slot (find-condition-class-slot class name)))
221 (error "missing slot ~S of ~S" name condition))
222 (dolist (initarg (condition-slot-initargs slot))
223 (let ((val (getf actual-initargs
225 *empty-condition-slot*)))
226 (unless (eq val *empty-condition-slot*)
227 (return-from condition-reader-function
228 (setf (getf (condition-assigned-slots condition)
231 (setf (getf (condition-assigned-slots condition) name)
232 (find-slot-default class slot)))
237 (defun make-condition (thing &rest args)
239 "Make an instance of a condition object using the specified initargs."
240 ;; Note: ANSI specifies no exceptional situations in this function.
241 ;; signalling simple-type-error would not be wrong.
242 (let* ((thing (if (symbolp thing)
243 (sb!xc:find-class thing)
245 (class (typecase thing
246 (condition-class thing)
248 (error 'simple-type-error
250 :expected-type 'condition-class
251 :format-control "~S is not a condition class."
252 :format-arguments (list thing)))
254 (error 'simple-type-error
256 :expected-type 'condition-class
257 :format-control "bad thing for class argument:~% ~S"
258 :format-arguments (list thing)))))
259 (res (make-condition-object args)))
260 (setf (%instance-layout res) (class-layout class))
261 ;; Set any class slots with initargs present in this call.
262 (dolist (cslot (condition-class-class-slots class))
263 (dolist (initarg (condition-slot-initargs cslot))
264 (let ((val (getf args initarg *empty-condition-slot*)))
265 (unless (eq val *empty-condition-slot*)
266 (setf (car (condition-slot-cell cslot)) val)))))
267 ;; Default any slots with non-constant defaults now.
268 (dolist (hslot (condition-class-hairy-slots class))
269 (when (dolist (initarg (condition-slot-initargs hslot) t)
270 (unless (eq (getf args initarg *empty-condition-slot*)
271 *empty-condition-slot*)
273 (setf (getf (condition-assigned-slots res) (condition-slot-name hslot))
274 (find-slot-default class hslot))))
278 ;;;; DEFINE-CONDITION
280 (eval-when (:compile-toplevel :load-toplevel :execute)
281 (defun %compiler-define-condition (name direct-supers layout)
282 (multiple-value-bind (class old-layout)
283 (insured-find-class name #'condition-class-p #'make-condition-class)
284 (setf (layout-class layout) class)
285 (setf (class-direct-superclasses class)
286 (mapcar #'sb!xc:find-class direct-supers))
287 (cond ((not old-layout)
288 (register-layout layout))
289 ((not *type-system-initialized*)
290 (setf (layout-class old-layout) class)
291 (setq layout old-layout)
292 (unless (eq (class-layout class) layout)
293 (register-layout layout)))
294 ((redefine-layout-warning "current"
297 (layout-length layout)
298 (layout-inherits layout)
299 (layout-depthoid layout))
300 (register-layout layout :invalidate t))
301 ((not (class-layout class))
302 (register-layout layout)))
304 (setf (layout-info layout)
306 ;; KLUDGE: There's a FIND-CLASS DEFTRANSFORM for constant class
307 ;; names which creates fast but non-cold-loadable, non-compact
308 ;; code. In this context, we'd rather have compact, cold-loadable
309 ;; code. -- WHN 19990928
310 (declare (notinline sb!xc:find-class))
311 (layout-info (class-layout (sb!xc:find-class 'condition)))))
313 (setf (sb!xc:find-class name) class)
315 ;; Initialize CPL slot from layout.
318 (let ((inherits (layout-inherits layout)))
319 (do ((i (1- (length inherits)) (1- i)))
321 (let ((super (sb!xc:find-class
323 (layout-class (svref inherits i))))))
324 (when (typep super 'condition-class)
326 (setf (condition-class-cpl class) (cpl))))
332 ;;; Compute the effective slots of class, copying inherited slots and
333 ;;; side-effecting direct slots.
334 (defun compute-effective-slots (class)
335 (collect ((res (copy-list (condition-class-slots class))))
336 (dolist (sclass (condition-class-cpl class))
337 (dolist (sslot (condition-class-slots sclass))
338 (let ((found (find (condition-slot-name sslot) (res)
341 (setf (condition-slot-initargs found)
342 (union (condition-slot-initargs found)
343 (condition-slot-initargs sslot)))
344 (unless (condition-slot-initform-p found)
345 (setf (condition-slot-initform-p found)
346 (condition-slot-initform-p sslot))
347 (setf (condition-slot-initform found)
348 (condition-slot-initform sslot)))
349 (unless (condition-slot-allocation found)
350 (setf (condition-slot-allocation found)
351 (condition-slot-allocation sslot))))
353 (res (copy-structure sslot)))))))
356 (defun %define-condition (name slots documentation report default-initargs)
357 (let ((class (sb!xc:find-class name)))
358 (setf (condition-class-slots class) slots)
359 (setf (condition-class-report class) report)
360 (setf (condition-class-default-initargs class) default-initargs)
361 (setf (fdocumentation name 'type) documentation)
365 ;; Set up reader and writer functions.
366 (let ((name (condition-slot-name slot)))
367 (dolist (reader (condition-slot-readers slot))
368 (setf (fdefinition reader)
369 #'(lambda (condition)
370 (condition-reader-function condition name))))
371 (dolist (writer (condition-slot-writers slot))
372 (setf (fdefinition writer)
373 #'(lambda (new-value condition)
374 (condition-writer-function condition new-value name))))))
376 ;; Compute effective slots and set up the class and hairy slots
377 ;; (subsets of the effective slots.)
378 (let ((eslots (compute-effective-slots class))
381 (mapcar #'condition-class-default-initargs
382 (condition-class-cpl class)))))
383 (dolist (slot eslots)
384 (ecase (condition-slot-allocation slot)
386 (unless (condition-slot-cell slot)
387 (setf (condition-slot-cell slot)
388 (list (if (condition-slot-initform-p slot)
389 (let ((initform (condition-slot-initform slot)))
390 (if (functionp initform)
393 *empty-condition-slot*))))
394 (push slot (condition-class-class-slots class)))
396 (setf (condition-slot-allocation slot) :instance)
397 (when (or (functionp (condition-slot-initform slot))
398 (dolist (initarg (condition-slot-initargs slot) nil)
399 (when (functionp (getf e-def-initargs initarg))
401 (push slot (condition-class-hairy-slots class))))))))
404 (defmacro define-condition (name (&rest parent-types) (&rest slot-specs)
407 "DEFINE-CONDITION Name (Parent-Type*) (Slot-Spec*) Option*
408 Define NAME as a condition type. This new type inherits slots and its
409 report function from the specified PARENT-TYPEs. A slot spec is a list of:
410 (slot-name :reader <rname> :initarg <iname> {Option Value}*
412 The DEFINE-CLASS slot options :ALLOCATION, :INITFORM, [slot] :DOCUMENTATION
413 and :TYPE and the overall options :DEFAULT-INITARGS and
414 [type] :DOCUMENTATION are also allowed.
416 The :REPORT option is peculiar to DEFINE-CONDITION. Its argument is either
417 a string or a two-argument lambda or function name. If a function, the
418 function is called with the condition and stream to report the condition.
419 If a string, the string is printed.
421 Condition types are classes, but (as allowed by ANSI and not as described in
422 CLtL2) are neither STANDARD-OBJECTs nor STRUCTURE-OBJECTs. WITH-SLOTS and
423 SLOT-VALUE may not be used on condition objects."
424 (let* ((parent-types (or parent-types '(condition)))
425 (layout (find-condition-layout name parent-types))
428 (default-initargs ()))
430 (all-readers nil append)
431 (all-writers nil append))
432 (dolist (spec slot-specs)
433 (when (keywordp spec)
434 (warn "Keyword slot name indicates probable syntax error:~% ~S"
436 (let* ((spec (if (consp spec) spec (list spec)))
437 (slot-name (first spec))
438 (allocation :instance)
444 (do ((options (rest spec) (cddr options)))
446 (unless (and (consp options) (consp (cdr options)))
447 (error "malformed condition slot spec:~% ~S." spec))
448 (let ((arg (second options)))
449 (case (first options)
450 (:reader (readers arg))
451 (:writer (writers arg))
454 (writers `(setf ,arg)))
457 (error "more than one :INITFORM in ~S" spec))
460 (:initarg (initargs arg))
462 (setq allocation arg))
465 (error "unknown slot option:~% ~S" (first options))))))
467 (all-readers (readers))
468 (all-writers (writers))
469 (slots `(make-condition-slot
471 :initargs ',(initargs)
474 :initform-p ',initform-p
476 ,(if (constantp initform)
478 `#'(lambda () ,initform)))))))
480 (dolist (option options)
481 (unless (consp option)
482 (error "bad option:~% ~S" option))
484 (:documentation (setq documentation (second option)))
486 (let ((arg (second option)))
489 `#'(lambda (condition stream)
490 (declare (ignore condition))
491 (write-string ,arg stream))
492 `#'(lambda (condition stream)
493 (funcall #',arg condition stream))))))
495 (do ((initargs (rest option) (cddr initargs)))
497 (let ((val (second initargs)))
498 (setq default-initargs
499 (list* `',(first initargs)
503 default-initargs)))))
505 (error "unknown option: ~S" (first option)))))
508 (warn "Condition slot setters probably not allowed in ANSI CL:~% ~S"
512 (eval-when (:compile-toplevel :load-toplevel :execute)
513 (%compiler-define-condition ',name ',parent-types ',layout))
515 (declaim (ftype (function (t) t) ,@(all-readers)))
516 (declaim (ftype (function (t t) t) ,@(all-writers)))
518 (%define-condition ',name
522 (list ,@default-initargs))))))
524 ;;;; DESCRIBE on CONDITIONs
526 ;;; a function to be used as the guts of DESCRIBE-OBJECT (CONDITION T)
527 ;;; eventually (once we get CLOS up and running so that we can define
529 (defun describe-condition (condition stream)
531 "~@<~S ~_is a ~S. ~_Its slot values are ~_~S.~:>"
535 (condition-actual-initargs condition)
536 (condition-assigned-slots condition))))
538 ;;;; various CONDITIONs specified by ANSI
540 (define-condition serious-condition (condition) ())
542 (define-condition error (serious-condition) ())
544 (define-condition warning (condition) ())
545 (define-condition style-warning (warning) ())
547 (defun simple-condition-printer (condition stream)
550 (simple-condition-format-control condition)
551 (simple-condition-format-arguments condition)))
553 (define-condition simple-condition ()
554 ((format-control :reader simple-condition-format-control
555 :initarg :format-control)
556 (format-arguments :reader simple-condition-format-arguments
557 :initarg :format-arguments
559 (:report simple-condition-printer))
561 (define-condition simple-warning (simple-condition warning) ())
563 ;;; This is the condition type used by ERROR and CERROR when
564 ;;; a format-control string is supplied as the first argument.
565 (define-condition simple-error (simple-condition error) ())
567 (define-condition storage-condition (serious-condition) ())
569 (define-condition type-error (error)
570 ((datum :reader type-error-datum :initarg :datum)
571 (expected-type :reader type-error-expected-type :initarg :expected-type))
573 (lambda (condition stream)
575 "~@<The value ~2I~:_~S ~I~_is not of type ~2I~_~S.~:>"
576 (type-error-datum condition)
577 (type-error-expected-type condition)))))
579 (define-condition program-error (error) ())
580 (define-condition parse-error (error) ())
581 (define-condition control-error (error) ())
582 (define-condition stream-error (error)
583 ((stream :reader stream-error-stream :initarg :stream)))
585 (define-condition end-of-file (stream-error) ()
587 (lambda (condition stream)
590 (stream-error-stream condition)))))
592 (define-condition file-error (error)
593 ((pathname :reader file-error-pathname :initarg :pathname))
595 (lambda (condition stream)
597 "~@<error on file ~_~S: ~2I~:_~?~:>"
598 (file-error-pathname condition)
599 ;; FIXME: ANSI's FILE-ERROR doesn't have FORMAT-CONTROL and
600 ;; FORMAT-ARGUMENTS, and the inheritance here doesn't seem
601 ;; to give us FORMAT-CONTROL or FORMAT-ARGUMENTS either.
602 ;; So how does this work?
603 (serious-condition-format-control condition)
604 (serious-condition-format-arguments condition)))))
606 (define-condition package-error (error)
607 ((package :reader package-error-package :initarg :package)))
609 (define-condition cell-error (error)
610 ((name :reader cell-error-name :initarg :name)))
612 (define-condition unbound-variable (cell-error) ()
614 (lambda (condition stream)
616 "The variable ~S is unbound."
617 (cell-error-name condition)))))
619 (define-condition undefined-function (cell-error) ()
621 (lambda (condition stream)
623 "The function ~S is undefined."
624 (cell-error-name condition)))))
626 (define-condition arithmetic-error (error)
627 ((operation :reader arithmetic-error-operation
630 (operands :reader arithmetic-error-operands
632 (:report (lambda (condition stream)
634 "arithmetic error ~S signalled"
636 (when (arithmetic-error-operation condition)
638 "~%Operation was ~S, operands ~S."
639 (arithmetic-error-operation condition)
640 (arithmetic-error-operands condition))))))
642 (define-condition division-by-zero (arithmetic-error) ())
643 (define-condition floating-point-overflow (arithmetic-error) ())
644 (define-condition floating-point-underflow (arithmetic-error) ())
645 (define-condition floating-point-inexact (arithmetic-error) ())
646 (define-condition floating-point-invalid-operation (arithmetic-error) ())
648 (define-condition print-not-readable (error)
649 ((object :reader print-not-readable-object :initarg :object))
651 (lambda (condition stream)
652 (let ((obj (print-not-readable-object condition))
654 (format stream "~S cannot be printed readably." obj)))))
656 (define-condition reader-error (parse-error stream-error)
658 :reader reader-error-format-control
659 :initarg :format-control)
661 :reader reader-error-format-arguments
662 :initarg :format-arguments
665 (lambda (condition stream)
666 (let ((error-stream (stream-error-stream condition)))
667 (format stream "READER-ERROR ~@[at ~D ~]on ~S:~%~?"
668 (file-position error-stream) error-stream
669 (reader-error-format-control condition)
670 (reader-error-format-arguments condition))))))
672 ;;;; various other (not specified by ANSI) CONDITIONs
674 ;;;; These might logically belong in other files; they're here, after
675 ;;;; setup of CONDITION machinery, only because that makes it easier to
676 ;;;; get cold init to work.
678 ;;; KLUDGE: a condition for floating point errors when we can't or
679 ;;; won't figure out what type they are. (In FreeBSD and OpenBSD we
680 ;;; don't know how, at least as of sbcl-0.6.7; in Linux we probably
681 ;;; know how but the old code was broken by the conversion to POSIX
682 ;;; signal handling and hasn't been fixed as of sbcl-0.6.7.)
684 ;;; FIXME: Perhaps this should also be a base class for all
685 ;;; floating point exceptions?
686 (define-condition floating-point-exception (arithmetic-error)
687 ((flags :initarg :traps
689 :reader floating-point-exception-traps))
690 (:report (lambda (condition stream)
692 "An arithmetic error ~S was signalled.~%"
694 (let ((traps (floating-point-exception-traps condition)))
697 "Trapping conditions are: ~%~{ ~S~^~}~%"
700 "No traps are enabled? How can this be?"
703 (define-condition index-too-large-error (type-error)
706 (lambda (condition stream)
708 "The index ~S is too large."
709 (type-error-datum condition)))))
711 (define-condition io-timeout (stream-error)
712 ((direction :reader io-timeout-direction :initarg :direction))
714 (lambda (condition stream)
715 (declare (type stream stream))
717 "I/O timeout ~(~A~)ing ~S"
718 (io-timeout-direction condition)
719 (stream-error-stream condition)))))
721 (define-condition namestring-parse-error (parse-error)
722 ((complaint :reader namestring-parse-error-complaint :initarg :complaint)
723 (arguments :reader namestring-parse-error-arguments :initarg :arguments
725 (namestring :reader namestring-parse-error-namestring :initarg :namestring)
726 (offset :reader namestring-parse-error-offset :initarg :offset))
728 (lambda (condition stream)
730 "parse error in namestring: ~?~% ~A~% ~V@T^"
731 (namestring-parse-error-complaint condition)
732 (namestring-parse-error-arguments condition)
733 (namestring-parse-error-namestring condition)
734 (namestring-parse-error-offset condition)))))
736 (define-condition simple-package-error (simple-condition package-error) ())
738 (define-condition reader-package-error (reader-error) ())
740 (define-condition reader-eof-error (end-of-file)
741 ((context :reader reader-eof-error-context :initarg :context))
743 (lambda (condition stream)
745 "unexpected end of file on ~S ~A"
746 (stream-error-stream condition)
747 (reader-eof-error-context condition)))))
749 ;;;; restart definitions
751 (define-condition abort-failure (control-error) ()
753 "An ABORT restart was found that failed to transfer control dynamically."))
755 (defun abort (&optional condition)
757 "Transfer control to a restart named ABORT, signalling a CONTROL-ERROR if
759 (invoke-restart (find-restart 'abort condition))
760 ;; ABORT signals an error in case there was a restart named ABORT
761 ;; that did not transfer control dynamically. This could happen with
763 (error 'abort-failure))
765 (defun muffle-warning (&optional condition)
767 "Transfer control to a restart named MUFFLE-WARNING, signalling a
768 CONTROL-ERROR if none exists."
769 (invoke-restart (find-restart 'muffle-warning condition)))
771 (macrolet ((define-nil-returning-restart (name args doc)
772 #!-sb-doc (declare (ignore doc))
773 `(defun ,name (,@args &optional condition)
775 ;; FIXME: Perhaps this shared logic should be pulled out into
776 ;; FLET MAYBE-INVOKE-RESTART? See whether it shrinks code..
777 (when (find-restart ',name condition)
778 (invoke-restart ',name ,@args)))))
779 (define-nil-returning-restart continue ()
780 "Transfer control to a restart named CONTINUE, or return NIL if none exists.")
781 (define-nil-returning-restart store-value (value)
782 "Transfer control and VALUE to a restart named STORE-VALUE, or return NIL if
784 (define-nil-returning-restart use-value (value)
785 "Transfer control and VALUE to a restart named USE-VALUE, or return NIL if
788 (/show0 "late-target-error.lisp end of file")