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!CONDITIONS")
18 ;;;; the CONDITION class
20 (eval-when (:compile-toplevel :load-toplevel :execute)
22 (def!struct (condition-class (:include slot-class)
23 (:constructor bare-make-condition-class))
24 ;; List of CONDITION-SLOT structures for the direct slots of this class.
25 (slots nil :type list)
26 ;; List of CONDITION-SLOT structures for all of the effective class slots of
28 (class-slots nil :type list)
29 ;; Report function or NIL.
30 (report nil :type (or function null))
31 ;; List of alternating initargs and initforms.
32 (default-initargs () :type list)
33 ;; CPL as a list of class objects, with all non-condition classes removed.
35 ;; A list of all the effective instance allocation slots of this class that
36 ;; have a non-constant initform or default-initarg. Values for these slots
37 ;; must be computed in the dynamic environment of MAKE-CONDITION.
38 (hairy-slots nil :type list))
40 (defun make-condition-class (&rest rest)
41 (apply #'bare-make-condition-class
42 (rename-keyword-args '((:name :%name)) rest)))
47 (:constructor make-condition-object (actual-initargs))
48 (:alternate-metaclass instance
54 ;; Actual initargs supplied to MAKE-CONDITION.
55 (actual-initargs (required-argument) :type list)
56 ;; Plist mapping slot names to any values that were assigned or defaulted
58 (assigned-slots () :type list))
60 (defstruct condition-slot
61 (name (required-argument) :type symbol)
62 ;; List of all applicable initargs.
63 (initargs (required-argument) :type list)
64 ;; Names of reader and writer functions.
65 (readers (required-argument) :type list)
66 (writers (required-argument) :type list)
67 ;; True if :INITFORM was specified.
68 (initform-p (required-argument) :type (member t nil))
69 ;; If a function, call it with no args. Otherwise, the actual value.
70 (initform (required-argument) :type t)
71 ;; Allocation of this slot. Nil only until defaulted.
72 (allocation nil :type (member :instance :class nil))
73 ;; If :class allocation, a cons whose car holds the value.
74 (cell nil :type (or cons null)))
76 (eval-when (#-sb-xc :compile-toplevel :load-toplevel :execute)
77 ;; the appropriate initialization value for the CPL slot of a CONDITION,
78 ;; calculated by looking at the INHERITS information in the LAYOUT
80 (defun condition-class-cpl-from-layout (condition)
81 (declare (type condition condition))
82 (let* ((class (sb!xc:find-class condition))
83 (layout (class-layout class))
84 (superset (map 'list #'identity (layout-inherits layout))))
85 (delete-if (lambda (superclass)
86 (not (typep superclass 'condition-class)))
89 ;;; KLUDGE: It's not clear to me why CONDITION-CLASS has itself listed in its
90 ;;; CPL, while other classes derived from CONDITION-CLASS don't have themselves
91 ;;; listed in their CPLs. This behavior is inherited from CMU CL, and didn't
92 ;;; seem to be explained there, and I haven't figured out whether it's right.
94 (eval-when (:compile-toplevel :load-toplevel :execute)
95 (let ((condition-class (locally
96 ;; KLUDGE: There's a FIND-CLASS DEFTRANSFORM for
97 ;; constant class names which creates fast but
98 ;; non-cold-loadable, non-compact code. In this
99 ;; context, we'd rather have compact, cold-loadable
100 ;; code. -- WHN 19990928
101 (declare (notinline sb!xc:find-class))
102 (sb!xc:find-class 'condition))))
103 (setf (condition-class-cpl condition-class)
104 (list condition-class))))
106 (setf (condition-class-report (locally
107 ;; KLUDGE: There's a FIND-CLASS DEFTRANSFORM
108 ;; for constant class names which creates fast
109 ;; but non-cold-loadable, non-compact code. In
110 ;; this context, we'd rather have compact,
111 ;; cold-loadable code. -- WHN 19990928
112 (declare (notinline sb!xc:find-class))
113 (find-class 'condition)))
114 #'(lambda (cond stream)
115 (format stream "Condition ~S was signalled." (type-of cond))))
117 (eval-when (:compile-toplevel :load-toplevel :execute)
119 (defun find-condition-layout (name parent-types)
120 (let* ((cpl (remove-duplicates
123 (mapcar #'(lambda (x)
125 (sb!xc:find-class x)))
127 (cond-layout (info :type :compiler-layout 'condition))
128 (olayout (info :type :compiler-layout name))
130 (concatenate 'simple-vector
131 (layout-inherits cond-layout)
132 (mapcar #'class-layout cpl))))
134 (not (mismatch (layout-inherits olayout) new-inherits)))
136 (make-layout :class (make-undefined-class name)
137 :inherits new-inherits
139 :length (layout-length cond-layout)))))
143 ;;; FIXME: ANSI's definition of DEFINE-CONDITION says
144 ;;; Condition reporting is mediated through the print-object method for
145 ;;; the condition type in question, with *print-escape* always being nil.
146 ;;; Specifying (:report report-name) in the definition of a condition
147 ;;; type C is equivalent to:
148 ;;; (defmethod print-object ((x c) stream)
149 ;;; (if *print-escape* (call-next-method) (report-name x stream)))
150 ;;; The current code doesn't seem to quite match that.
151 (def!method print-object ((x condition) stream)
153 (print-unreadable-object (x stream :type t :identity t))
154 ;; KLUDGE: A comment from CMU CL here said
155 ;; 7/13/98 BUG? CPL is not sorted and results here depend on order of
156 ;; superclasses in define-condition call!
157 (dolist (class (condition-class-cpl (sb!xc:class-of x))
158 (error "no REPORT? shouldn't happen!"))
159 (let ((report (condition-class-report class)))
161 (return (funcall report x stream)))))))
163 ;;;; slots of CONDITION objects
165 (defvar *empty-slot* '(empty))
167 (defun find-slot-default (class slot)
168 (let ((initargs (condition-slot-initargs slot))
169 (cpl (condition-class-cpl class)))
171 (let ((default-initargs (condition-class-default-initargs class)))
172 (dolist (initarg initargs)
173 (let ((val (getf default-initargs initarg *empty-slot*)))
174 (unless (eq val *empty-slot*)
175 (return-from find-slot-default
180 (if (condition-slot-initform-p slot)
181 (let ((initform (condition-slot-initform slot)))
182 (if (functionp initform)
185 (error "unbound condition slot: ~S" (condition-slot-name slot)))))
187 (defun find-slot (classes name)
188 (dolist (sclass classes nil)
189 (dolist (slot (condition-class-slots sclass))
190 (when (eq (condition-slot-name slot) name)
191 (return-from find-slot slot)))))
193 (defun condition-writer-function (condition new-value name)
194 (dolist (cslot (condition-class-class-slots
195 (layout-class (%instance-layout condition)))
196 (setf (getf (condition-assigned-slots condition) name)
198 (when (eq (condition-slot-name cslot) name)
199 (return (setf (car (condition-slot-cell cslot)) new-value)))))
201 (defun condition-reader-function (condition name)
202 (let ((class (layout-class (%instance-layout condition))))
203 (dolist (cslot (condition-class-class-slots class))
204 (when (eq (condition-slot-name cslot) name)
205 (return-from condition-reader-function
206 (car (condition-slot-cell cslot)))))
208 (let ((val (getf (condition-assigned-slots condition) name
210 (if (eq val *empty-slot*)
211 (let ((actual-initargs (condition-actual-initargs condition))
212 (slot (find-slot (condition-class-cpl class) name)))
213 (dolist (initarg (condition-slot-initargs slot))
214 (let ((val (getf actual-initargs initarg *empty-slot*)))
215 (unless (eq val *empty-slot*)
216 (return-from condition-reader-function
217 (setf (getf (condition-assigned-slots condition)
220 (setf (getf (condition-assigned-slots condition) name)
221 (find-slot-default class slot)))
226 (defun make-condition (thing &rest args)
228 "Make an instance of a condition object using the specified initargs."
229 ;; Note: ANSI specifies no exceptional situations in this function.
230 ;; signalling simple-type-error would not be wrong.
231 (let* ((thing (if (symbolp thing)
232 (sb!xc:find-class thing)
234 (class (typecase thing
235 (condition-class thing)
237 (error 'simple-type-error
239 :expected-type 'condition-class
240 :format-control "~S is not a condition class."
241 :format-arguments (list thing)))
243 (error 'simple-type-error
245 :expected-type 'condition-class
246 :format-control "bad thing for class arg:~% ~S"
247 :format-arguments (list thing)))))
248 (res (make-condition-object args)))
249 (setf (%instance-layout res) (class-layout class))
250 ;; Set any class slots with initargs present in this call.
251 (dolist (cslot (condition-class-class-slots class))
252 (dolist (initarg (condition-slot-initargs cslot))
253 (let ((val (getf args initarg *empty-slot*)))
254 (unless (eq val *empty-slot*)
255 (setf (car (condition-slot-cell cslot)) val)))))
256 ;; Default any slots with non-constant defaults now.
257 (dolist (hslot (condition-class-hairy-slots class))
258 (when (dolist (initarg (condition-slot-initargs hslot) t)
259 (unless (eq (getf args initarg *empty-slot*) *empty-slot*)
261 (setf (getf (condition-assigned-slots res) (condition-slot-name hslot))
262 (find-slot-default class hslot))))
266 ;;;; DEFINE-CONDITION
268 (eval-when (:compile-toplevel :load-toplevel :execute)
269 (defun %compiler-define-condition (name direct-supers layout)
270 (multiple-value-bind (class old-layout)
271 (insured-find-class name #'condition-class-p #'make-condition-class)
272 (setf (layout-class layout) class)
273 (setf (class-direct-superclasses class)
274 (mapcar #'sb!xc:find-class direct-supers))
275 (cond ((not old-layout)
276 (register-layout layout))
277 ((not *type-system-initialized*)
278 (setf (layout-class old-layout) class)
279 (setq layout old-layout)
280 (unless (eq (class-layout class) layout)
281 (register-layout layout)))
282 ((redefine-layout-warning "current"
285 (layout-length layout)
286 (layout-inherits layout)
287 (layout-depthoid layout))
288 (register-layout layout :invalidate t))
289 ((not (class-layout class))
290 (register-layout layout)))
292 (setf (layout-info layout)
294 ;; KLUDGE: There's a FIND-CLASS DEFTRANSFORM for constant class
295 ;; names which creates fast but non-cold-loadable, non-compact
296 ;; code. In this context, we'd rather have compact, cold-loadable
297 ;; code. -- WHN 19990928
298 (declare (notinline sb!xc:find-class))
299 (layout-info (class-layout (sb!xc:find-class 'condition)))))
301 (setf (sb!xc:find-class name) class)
303 ;; Initialize CPL slot from layout.
306 (let ((inherits (layout-inherits layout)))
307 (do ((i (1- (length inherits)) (1- i)))
309 (let ((super (sb!xc:find-class
311 (layout-class (svref inherits i))))))
312 (when (typep super 'condition-class)
314 (setf (condition-class-cpl class) (cpl))))
320 ;;; Compute the effective slots of class, copying inherited slots and
321 ;;; side-effecting direct slots.
322 (defun compute-effective-slots (class)
323 (collect ((res (copy-list (condition-class-slots class))))
324 (dolist (sclass (condition-class-cpl class))
325 (dolist (sslot (condition-class-slots sclass))
326 (let ((found (find (condition-slot-name sslot) (res)
329 (setf (condition-slot-initargs found)
330 (union (condition-slot-initargs found)
331 (condition-slot-initargs sslot)))
332 (unless (condition-slot-initform-p found)
333 (setf (condition-slot-initform-p found)
334 (condition-slot-initform-p sslot))
335 (setf (condition-slot-initform found)
336 (condition-slot-initform sslot)))
337 (unless (condition-slot-allocation found)
338 (setf (condition-slot-allocation found)
339 (condition-slot-allocation sslot))))
341 (res (copy-structure sslot)))))))
344 (defun %define-condition (name slots documentation report default-initargs)
345 (let ((class (sb!xc:find-class name)))
346 (setf (condition-class-slots class) slots)
347 (setf (condition-class-report class) report)
348 (setf (condition-class-default-initargs class) default-initargs)
349 (setf (fdocumentation name 'type) documentation)
353 ;; Set up reader and writer functions.
354 (let ((name (condition-slot-name slot)))
355 (dolist (reader (condition-slot-readers slot))
356 (setf (fdefinition reader)
357 #'(lambda (condition)
358 (condition-reader-function condition name))))
359 (dolist (writer (condition-slot-writers slot))
360 (setf (fdefinition writer)
361 #'(lambda (new-value condition)
362 (condition-writer-function condition new-value name))))))
364 ;; Compute effective slots and set up the class and hairy slots (subsets of
365 ;; the effective slots.)
366 (let ((eslots (compute-effective-slots class))
369 (mapcar #'condition-class-default-initargs
370 (condition-class-cpl class)))))
371 (dolist (slot eslots)
372 (ecase (condition-slot-allocation slot)
374 (unless (condition-slot-cell slot)
375 (setf (condition-slot-cell slot)
376 (list (if (condition-slot-initform-p slot)
377 (let ((initform (condition-slot-initform slot)))
378 (if (functionp initform)
382 (push slot (condition-class-class-slots class)))
384 (setf (condition-slot-allocation slot) :instance)
385 (when (or (functionp (condition-slot-initform slot))
386 (dolist (initarg (condition-slot-initargs slot) nil)
387 (when (functionp (getf e-def-initargs initarg))
389 (push slot (condition-class-hairy-slots class))))))))
392 (defmacro define-condition (name (&rest parent-types) (&rest slot-specs)
395 "DEFINE-CONDITION Name (Parent-Type*) (Slot-Spec*) Option*
396 Define NAME as a condition type. This new type inherits slots and its
397 report function from the specified PARENT-TYPEs. A slot spec is a list of:
398 (slot-name :reader <rname> :initarg <iname> {Option Value}*
400 The DEFINE-CLASS slot options :ALLOCATION, :INITFORM, [slot] :DOCUMENTATION
401 and :TYPE and the overall options :DEFAULT-INITARGS and
402 [type] :DOCUMENTATION are also allowed.
404 The :REPORT option is peculiar to DEFINE-CONDITION. Its argument is either
405 a string or a two-argument lambda or function name. If a function, the
406 function is called with the condition and stream to report the condition.
407 If a string, the string is printed.
409 Condition types are classes, but (as allowed by ANSI and not as described in
410 CLtL2) are neither STANDARD-OBJECTs nor STRUCTURE-OBJECTs. WITH-SLOTS and
411 SLOT-VALUE may not be used on condition objects."
412 (let* ((parent-types (or parent-types '(condition)))
413 (layout (find-condition-layout name parent-types))
416 (default-initargs ()))
418 (all-readers nil append)
419 (all-writers nil append))
420 (dolist (spec slot-specs)
421 (when (keywordp spec)
422 (warn "Keyword slot name indicates probable syntax error:~% ~S"
424 (let* ((spec (if (consp spec) spec (list spec)))
425 (slot-name (first spec))
426 (allocation :instance)
432 (do ((options (rest spec) (cddr options)))
434 (unless (and (consp options) (consp (cdr options)))
435 (error "malformed condition slot spec:~% ~S." spec))
436 (let ((arg (second options)))
437 (case (first options)
438 (:reader (readers arg))
439 (:writer (writers arg))
442 (writers `(setf ,arg)))
445 (error "more than one :INITFORM in ~S" spec))
448 (:initarg (initargs arg))
450 (setq allocation arg))
453 (error "unknown slot option:~% ~S" (first options))))))
455 (all-readers (readers))
456 (all-writers (writers))
457 (slots `(make-condition-slot
459 :initargs ',(initargs)
462 :initform-p ',initform-p
464 ,(if (constantp initform)
466 `#'(lambda () ,initform)))))))
468 (dolist (option options)
469 (unless (consp option)
470 (error "bad option:~% ~S" option))
472 (:documentation (setq documentation (second option)))
474 (let ((arg (second option)))
477 `#'(lambda (condition stream)
478 (declare (ignore condition))
479 (write-string ,arg stream))
480 `#'(lambda (condition stream)
481 (funcall #',arg condition stream))))))
483 (do ((initargs (rest option) (cddr initargs)))
485 (let ((val (second initargs)))
486 (setq default-initargs
487 (list* `',(first initargs)
491 default-initargs)))))
493 (error "unknown option: ~S" (first option)))))
496 (warn "Condition slot setters probably not allowed in ANSI CL:~% ~S"
500 (eval-when (:compile-toplevel :load-toplevel :execute)
501 (%compiler-define-condition ',name ',parent-types ',layout))
503 (declaim (ftype (function (t) t) ,@(all-readers)))
504 (declaim (ftype (function (t t) t) ,@(all-writers)))
506 (%define-condition ',name
510 (list ,@default-initargs))))))
512 ;;;; various CONDITIONs specified by ANSI
514 (define-condition serious-condition (condition)())
516 (define-condition error (serious-condition) ())
518 (define-condition warning (condition) ())
519 (define-condition style-warning (warning) ())
521 (defun simple-condition-printer (condition stream)
522 ;; FIXME: Why use APPLY instead of an ordinary form? To stop the optimizer
523 ;; from doing something?
524 (apply #'format stream (simple-condition-format-control condition)
525 (simple-condition-format-arguments condition)))
527 (define-condition simple-condition ()
528 ((format-control :reader simple-condition-format-control
529 :initarg :format-control)
530 (format-arguments :reader simple-condition-format-arguments
531 :initarg :format-arguments
533 (:report simple-condition-printer))
535 (define-condition simple-warning (simple-condition warning) ())
537 (defun print-simple-error (condition stream)
539 "~&~@<error in function ~S: ~3I~:_~?~:>"
540 (condition-function-name condition)
541 (simple-condition-format-control condition)
542 (simple-condition-format-arguments condition)))
544 (define-condition simple-error (simple-condition error) ()
545 ;; This is the condition type used by ERROR and CERROR when
546 ;; a format-control string is supplied as the first argument.
547 (:report print-simple-error))
549 (define-condition storage-condition (serious-condition) ())
551 ;;; FIXME: Should we really be reporting CONDITION-FUNCTION-NAME data on an
552 ;;; ad hoc basis, for some conditions and not others? Why not standardize
553 ;;; it somehow? perhaps by making the debugger report it?
555 (define-condition type-error (error)
556 ((datum :reader type-error-datum :initarg :datum)
557 (expected-type :reader type-error-expected-type :initarg :expected-type))
559 (lambda (condition stream)
561 "~@<TYPE-ERROR in ~S: ~3I~:_~S is not of type ~S~:>."
562 (condition-function-name condition)
563 (type-error-datum condition)
564 (type-error-expected-type condition)))))
566 (define-condition program-error (error) ())
567 (define-condition parse-error (error) ())
568 (define-condition control-error (error) ())
569 (define-condition stream-error (error)
570 ((stream :reader stream-error-stream :initarg :stream)))
572 (define-condition end-of-file (stream-error) ()
574 (lambda (condition stream)
577 (stream-error-stream condition)))))
579 (define-condition file-error (error)
580 ((pathname :reader file-error-pathname :initarg :pathname))
582 (lambda (condition stream)
584 "~&~@<FILE-ERROR in function ~S: ~3i~:_~?~:>"
585 (condition-function-name condition)
586 (serious-condition-format-control condition)
587 (serious-condition-format-arguments condition)))))
589 (define-condition package-error (error)
590 ((package :reader package-error-package :initarg :package)))
592 (define-condition cell-error (error)
593 ((name :reader cell-error-name :initarg :name)))
595 (define-condition unbound-variable (cell-error) ()
597 (lambda (condition stream)
599 "error in ~S: The variable ~S is unbound."
600 (condition-function-name condition)
601 (cell-error-name condition)))))
603 (define-condition undefined-function (cell-error) ()
605 (lambda (condition stream)
607 "error in ~S: The function ~S is undefined."
608 (condition-function-name condition)
609 (cell-error-name condition)))))
611 (define-condition arithmetic-error (error)
612 ((operation :reader arithmetic-error-operation
615 (operands :reader arithmetic-error-operands
617 (:report (lambda (condition stream)
619 "arithmetic error ~S signalled"
621 (when (arithmetic-error-operation condition)
623 "~%Operation was ~S, operands ~S."
624 (arithmetic-error-operation condition)
625 (arithmetic-error-operands condition))))))
627 (define-condition division-by-zero (arithmetic-error) ())
628 (define-condition floating-point-overflow (arithmetic-error) ())
629 (define-condition floating-point-underflow (arithmetic-error) ())
630 (define-condition floating-point-inexact (arithmetic-error) ())
631 (define-condition floating-point-invalid-operation (arithmetic-error) ())
633 (define-condition print-not-readable (error)
634 ((object :reader print-not-readable-object :initarg :object))
636 (lambda (condition stream)
637 (let ((obj (print-not-readable-object condition))
639 (format stream "~S cannot be printed readably." obj)))))
641 (define-condition reader-error (parse-error stream-error)
643 :reader reader-error-format-control
644 :initarg :format-control)
646 :reader reader-error-format-arguments
647 :initarg :format-arguments
650 (lambda (condition stream)
651 (let ((error-stream (stream-error-stream condition)))
652 (format stream "READER-ERROR ~@[at ~D ~]on ~S:~%~?"
653 (file-position error-stream) error-stream
654 (reader-error-format-control condition)
655 (reader-error-format-arguments condition))))))
657 ;;;; various other (not specified by ANSI) CONDITIONs
659 ;;;; These might logically belong in other files; they're here, after
660 ;;;; setup of CONDITION machinery, only because that makes it easier to
661 ;;;; get cold init to work.
663 ;;; KLUDGE: a condition for floating point errors when we can't or
664 ;;; won't figure out what type they are. (In FreeBSD and OpenBSD we
665 ;;; don't know how, at least as of sbcl-0.6.7; in Linux we probably
666 ;;; know how but the old code was broken by the conversion to POSIX
667 ;;; signal handling and hasn't been fixed as of sbcl-0.6.7.)
669 ;;; FIXME: Perhaps this should also be a base class for all
670 ;;; floating point exceptions?
671 (define-condition floating-point-exception (arithmetic-error)
672 ((flags :initarg :traps
673 :reader floating-point-exception-traps))
674 (:report (lambda (condition stream)
676 "An arithmetic error ~S was signalled.~%"
678 (let ((traps (floating-point-exception-traps condition)))
681 "Trapping conditions are: ~%~{ ~S~^~}~%"
684 "No traps are enabled? How can this be?"
687 (define-condition index-too-large-error (type-error)
690 (lambda (condition stream)
692 "error in ~S: ~S: index too large"
693 (condition-function-name condition)
694 (type-error-datum condition)))))
696 (define-condition io-timeout (stream-error)
697 ((direction :reader io-timeout-direction :initarg :direction))
699 (lambda (condition stream)
700 (declare (type stream stream))
702 "IO-TIMEOUT ~(~A~)ing ~S"
703 (io-timeout-direction condition)
704 (stream-error-stream condition)))))
706 (define-condition namestring-parse-error (parse-error)
707 ((complaint :reader namestring-parse-error-complaint :initarg :complaint)
708 (arguments :reader namestring-parse-error-arguments :initarg :arguments
710 (namestring :reader namestring-parse-error-namestring :initarg :namestring)
711 (offset :reader namestring-parse-error-offset :initarg :offset))
712 (:report %print-namestring-parse-error))
714 (define-condition simple-package-error (simple-condition package-error) ())
716 (define-condition reader-package-error (reader-error) ())
718 (define-condition reader-eof-error (end-of-file)
719 ((context :reader reader-eof-error-context :initarg :context))
721 (lambda (condition stream)
723 "unexpected EOF on ~S ~A"
724 (stream-error-stream condition)
725 (reader-eof-error-context condition)))))
727 ;;;; restart definitions
729 (define-condition abort-failure (control-error) ()
731 "An ABORT restart was found that failed to transfer control dynamically."))
733 (defun abort (&optional condition)
735 "Transfer control to a restart named ABORT, signalling a CONTROL-ERROR if
737 (invoke-restart (find-restart 'abort condition))
738 ;; ABORT signals an error in case there was a restart named abort that did
739 ;; not transfer control dynamically. This could happen with RESTART-BIND.
740 (error 'abort-failure))
742 (defun muffle-warning (&optional condition)
744 "Transfer control to a restart named MUFFLE-WARNING, signalling a
745 CONTROL-ERROR if none exists."
746 (invoke-restart (find-restart 'muffle-warning condition)))
748 (macrolet ((define-nil-returning-restart (name args doc)
749 #!-sb-doc (declare (ignore doc))
750 `(defun ,name (,@args &optional condition)
752 ;; FIXME: Perhaps this shared logic should be pulled out into
753 ;; FLET MAYBE-INVOKE-RESTART? See whether it shrinks code..
754 (when (find-restart ',name condition)
755 (invoke-restart ',name ,@args)))))
756 (define-nil-returning-restart continue ()
757 "Transfer control to a restart named CONTINUE, or return NIL if none exists.")
758 (define-nil-returning-restart store-value (value)
759 "Transfer control and VALUE to a restart named STORE-VALUE, or return NIL if
761 (define-nil-returning-restart use-value (value)
762 "Transfer control and VALUE to a restart named USE-VALUE, or return NIL if