define-error to throw custom errors.
But it looks like this function wasn't yet implemented in
emacs-24.3, for instance.
It still seems to work for
emacs-24.3 if I write this:
(when (version< emacs-version "24.4") (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 #'nconc (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)))))
Is this the proper way to get
define-error in older Emacs? What was used before it was implemented?