Function: define-error

define-error is a byte-compiled function defined in subr.el.gz.

Signature

(define-error NAME MESSAGE &optional PARENT)

Documentation

Define NAME as a new error signal.

MESSAGE is a string that will be output to the echo area if such an error is signaled without being caught by a condition-case. PARENT is either a signal or a list of signals from which it inherits. Defaults to error.

View in manual

Probably introduced at or before Emacs version 24.4.

Aliases

org-define-error (obsolete since 9.6)

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun define-error (name message &optional parent)
  "Define NAME as a new error signal.
MESSAGE is a string that will be output to the echo area if such an error
is signaled without being caught by a `condition-case'.
PARENT is either a signal or a list of signals from which it inherits.
Defaults to `error'."
  (unless parent (setq parent 'error))
  (let ((conditions
         (if (consp parent)
             (apply #'append
                    (mapcar (lambda (parent)
                              (cons parent
                                    (or (get parent 'error-conditions)
                                        (error "Unknown signal `%s'" parent))))
                            parent))
           (cons parent (get parent 'error-conditions)))))
    (put name 'error-conditions
         (delete-dups (copy-sequence (cons name conditions))))
    (when message (put name 'error-message message))))