diff options
| author | Stefan Monnier | 2026-03-10 10:31:14 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2026-03-10 10:48:22 -0400 |
| commit | fa6f2cb63c887ab322f7146fd65b1642348f6718 (patch) | |
| tree | ebc60e0066df850d57c4dd7c269762f49745f147 /lisp/epa-file.el | |
| parent | 6d8b3d1077278b5c22652c796d3d878880cca1f3 (diff) | |
| download | emacs-scratch/error-API.tar.gz emacs-scratch/error-API.zip | |
(error-data): Delete functionscratch/error-API
Remove `error-data` from the new error API: it is not really
compatible with a more abstract view of error descriptors, and
in practice it seems to be used only in two ways (both of them rare):
- To add some contextual info to an error. We should maybe add
a dedicated support for that, but it's not clear what shape it
should take, ideally (there was a discussion about with Alan
and myself in emacs-devel a few years ago).
- To do some other massaging whose correctness is dubious anyway.
* doc/lispref/control.texi (Handling Errors): Remove `error-data`.
* lisp/epa-file.el (epa-file--find-file-not-found-function): Don't use
`error-data`.
(epa-file--error-add-context): New function, extracted from
`epa-file-insert-file-contents`.
(epa-file-insert-file-contents): Use it instead of `error-data`.
* lisp/subr.el (error-data): Delete function.
Diffstat (limited to 'lisp/epa-file.el')
| -rw-r--r-- | lisp/epa-file.el | 18 |
1 files changed, 13 insertions, 5 deletions
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." | |||
| 116 | (defun epa-file--find-file-not-found-function () | 116 | (defun epa-file--find-file-not-found-function () |
| 117 | (let ((error epa-file-error)) | 117 | (let ((error epa-file-error)) |
| 118 | (save-window-excursion | 118 | (save-window-excursion |
| 119 | (kill-buffer)) | 119 | (kill-buffer)) |
| 120 | ;; FIXME: How do we know that slot 3 can hold only a message related | ||
| 121 | ;; to a wrong passphrase? | ||
| 120 | (if (error-slot-value error 3) | 122 | (if (error-slot-value error 3) |
| 121 | (user-error "Wrong passphrase: %s" (error-slot-value error 3)) | 123 | (user-error "Wrong passphrase: %s" (error-slot-value error 3)) |
| 124 | ;; FIXME: Why does it make sense to add the data fields of ERROR, | ||
| 125 | ;; shifted by one position? | ||
| 122 | (signal 'file-missing | 126 | (signal 'file-missing |
| 123 | (cons "Opening input file" (error-data error)))))) | 127 | (cons "Opening input file" (cdr error)))))) |
| 124 | 128 | ||
| 125 | (defun epa--wrong-password-p (context) | 129 | (defun epa--wrong-password-p (context) |
| 126 | "Return whether a wrong password caused the error in CONTEXT." | 130 | "Return whether a wrong password caused the error in CONTEXT." |
| @@ -136,6 +140,9 @@ encryption is used." | |||
| 136 | error-string) | 140 | error-string) |
| 137 | (match-string 1 error-string)))) | 141 | (match-string 1 error-string)))) |
| 138 | 142 | ||
| 143 | (defun epa-file--error-add-context (err ctxt) | ||
| 144 | (setf (cdr error) (append (cdr error) (list ctx)))) | ||
| 145 | |||
| 139 | (defvar last-coding-system-used) | 146 | (defvar last-coding-system-used) |
| 140 | (defun epa-file-insert-file-contents (file &optional visit beg end replace) | 147 | (defun epa-file-insert-file-contents (file &optional visit beg end replace) |
| 141 | (barf-if-buffer-read-only) | 148 | (barf-if-buffer-read-only) |
| @@ -182,8 +189,7 @@ encryption is used." | |||
| 182 | ;; Don't display the *error* buffer if we just | 189 | ;; Don't display the *error* buffer if we just |
| 183 | ;; have a wrong password; let the later error | 190 | ;; have a wrong password; let the later error |
| 184 | ;; handler notify the user. | 191 | ;; handler notify the user. |
| 185 | (setf (error-data error) | 192 | (epa-file--error-add-context error wrong-password) |
| 186 | (append (error-data error) (list wrong-password))) | ||
| 187 | (epa-display-error context)) | 193 | (epa-display-error context)) |
| 188 | ;; When the .gpg file isn't an encrypted file (e.g., | 194 | ;; When the .gpg file isn't an encrypted file (e.g., |
| 189 | ;; it's a keyring.gpg file instead), then gpg will | 195 | ;; it's a keyring.gpg file instead), then gpg will |
| @@ -201,8 +207,10 @@ encryption is used." | |||
| 201 | (add-hook 'find-file-not-found-functions | 207 | (add-hook 'find-file-not-found-functions |
| 202 | #'epa-file--find-file-not-found-function | 208 | #'epa-file--find-file-not-found-function |
| 203 | nil t))) | 209 | nil t))) |
| 210 | ;; FIXME: Why does it make sense to add the data fields | ||
| 211 | ;; of ERROR, shifted by one position? | ||
| 204 | (signal (if exists 'file-error 'file-missing) | 212 | (signal (if exists 'file-error 'file-missing) |
| 205 | (cons "Opening input file" (error-data error)))))) | 213 | (cons "Opening input file" (cdr error)))))) |
| 206 | (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! | 214 | (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! |
| 207 | (setq-local epa-file-encrypt-to | 215 | (setq-local epa-file-encrypt-to |
| 208 | (mapcar #'car (epg-context-result-for | 216 | (mapcar #'car (epg-context-result-for |