diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi index 3925bdd1b40..d3662f727cc 100644 --- a/doc/lispref/control.texi +++ b/doc/lispref/control.texi @@ -2483,10 +2483,6 @@ to @code{condition-case} whose error condition you want to re-throw. This function returns the error symbol of the error descriptor @var{error}. @end defun -@defun error-data error -This function returns the data of the error descriptor @var{error}. -@end defun - @defun error-slot-value error pos This function returns the value in the field number @var{pos} of the error descriptor @var{error}. The fields are numbered starting with 1. E.g., diff --git a/lisp/epa-file.el b/lisp/epa-file.el index ced54b6eeed..e45dbd1754e 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -116,11 +116,15 @@ encryption is used." (defun epa-file--find-file-not-found-function () (let ((error epa-file-error)) (save-window-excursion - (kill-buffer)) + (kill-buffer)) + ;; FIXME: How do we know that slot 3 can hold only a message related + ;; to a wrong passphrase? (if (error-slot-value error 3) (user-error "Wrong passphrase: %s" (error-slot-value error 3)) + ;; FIXME: Why does it make sense to add the data fields of ERROR, + ;; shifted by one position? (signal 'file-missing - (cons "Opening input file" (error-data error)))))) + (cons "Opening input file" (cdr error)))))) (defun epa--wrong-password-p (context) "Return whether a wrong password caused the error in CONTEXT." @@ -136,6 +140,9 @@ encryption is used." error-string) (match-string 1 error-string)))) +(defun epa-file--error-add-context (err ctxt) + (setf (cdr error) (append (cdr error) (list ctx)))) + (defvar last-coding-system-used) (defun epa-file-insert-file-contents (file &optional visit beg end replace) (barf-if-buffer-read-only) @@ -182,8 +189,7 @@ encryption is used." ;; Don't display the *error* buffer if we just ;; have a wrong password; let the later error ;; handler notify the user. - (setf (error-data error) - (append (error-data error) (list wrong-password))) + (epa-file--error-add-context error wrong-password) (epa-display-error context)) ;; When the .gpg file isn't an encrypted file (e.g., ;; it's a keyring.gpg file instead), then gpg will @@ -201,8 +207,10 @@ encryption is used." (add-hook 'find-file-not-found-functions #'epa-file--find-file-not-found-function nil t))) + ;; FIXME: Why does it make sense to add the data fields + ;; of ERROR, shifted by one position? (signal (if exists 'file-error 'file-missing) - (cons "Opening input file" (error-data error)))))) + (cons "Opening input file" (cdr error)))))) (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! (setq-local epa-file-encrypt-to (mapcar #'car (epg-context-result-for diff --git a/lisp/subr.el b/lisp/subr.el index 3cf4e8276d6..0c2acfec335 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -586,10 +586,6 @@ Defaults to `error'." "Return the symbol which represents the type of ERROR. \n(fn ERROR)") -(defalias 'error-data #'cdr - "Return the slots attached to ERROR, as a list. -\n(fn ERROR)") - (defun error-has-type-p (error condition) "Return non-nil if ERROR is of type CONDITION (or a subtype of it)." (unless (error--p error)