Error handling clarifications found during error-API
* lisp/simple.el (next-line, previous-line): Remove useless `condition-case` handler, and hence the whole `condition-case`, and then simplify. * lisp/emacs-lisp/comp.el (comp--error-add-context): New function. (comp--native-compile): Use it. * lisp/gnus/nnrss.el (nnrss-insert): Use `with-demoted-errors`.
This commit is contained in:
parent
a9432736f7
commit
3118a8c8b1
3 changed files with 40 additions and 43 deletions
|
|
@ -3528,6 +3528,21 @@ session."
|
|||
(rename-file newfile oldfile t)
|
||||
(delete-file oldfile)))))
|
||||
|
||||
(defun comp--error-add-context (err ctxt)
|
||||
"Add context information CTXT to the error descriptor ERR."
|
||||
;; There is currently no agreed upon way to do that, and if we want the
|
||||
;; context to be displayed, the only option currently is to add elements
|
||||
;; to the error descriptor.
|
||||
(let ((err-data (cdr err)))
|
||||
(setf (cdr err)
|
||||
(if (not (listp err-data)) ;; This should never happen.
|
||||
(list err-data ctxt)
|
||||
;; We can't just insert arbitrary info in the
|
||||
;; error-data part of an error: the handler may
|
||||
;; expect specific data at specific positions,
|
||||
;; so add our info at the end.
|
||||
(append err-data (list ctxt))))))
|
||||
|
||||
(defun comp--native-compile (function-or-file &optional with-late-load output)
|
||||
"Compile FUNCTION-OR-FILE into native code.
|
||||
When WITH-LATE-LOAD is non-nil, mark the compilation unit for late
|
||||
|
|
@ -3577,25 +3592,21 @@ the deferred compilation mechanism."
|
|||
pass time)
|
||||
0))))
|
||||
(t
|
||||
(let ((err-val (cdr err)))
|
||||
;; If we are doing an async native compilation print the
|
||||
;; error in the correct format so is parsable and abort.
|
||||
(if (and comp-async-compilation
|
||||
(not (eq (car err) 'native-compiler-error)))
|
||||
(progn
|
||||
(message "%S: Error %s"
|
||||
function-or-file
|
||||
(error-message-string err))
|
||||
(kill-emacs -1))
|
||||
;; Otherwise re-signal it adding the compilation input.
|
||||
;; FIXME: We can't just insert arbitrary info in the
|
||||
;; error-data part of an error: the handler may expect
|
||||
;; specific data at specific positions!
|
||||
(signal (car err) (if (consp err-val)
|
||||
(cons function-or-file err-val)
|
||||
;; FIXME: `err-val' is supposed to be
|
||||
;; a list, so it can only be nil here!
|
||||
(list function-or-file err-val)))))))
|
||||
;; If we are doing an async native compilation print the
|
||||
;; error in the correct format so is parsable and abort.
|
||||
(if (and comp-async-compilation
|
||||
(not (eq (car err) 'native-compiler-error)))
|
||||
(progn
|
||||
(message "%S: Error %s"
|
||||
function-or-file
|
||||
(error-message-string err))
|
||||
(kill-emacs -1))
|
||||
;; Otherwise re-signal it adding the compilation input.
|
||||
;; FIXME: We can't just insert arbitrary info in the
|
||||
;; error-data part of an error: the handler may expect
|
||||
;; specific data at specific positions!
|
||||
(comp--error-add-context err function-or-file)
|
||||
(signal (car err) (cdr err)))))
|
||||
(if (stringp function-or-file)
|
||||
data
|
||||
;; So we return the compiled function.
|
||||
|
|
|
|||
|
|
@ -567,11 +567,8 @@ which RSS 2.0 allows."
|
|||
"")
|
||||
|
||||
(defun nnrss-insert (url)
|
||||
(condition-case err
|
||||
(mm-url-insert url)
|
||||
(error (if (or debug-on-quit debug-on-error)
|
||||
(signal (car err) (cdr err))
|
||||
(message "nnrss: Failed to fetch %s" url)))))
|
||||
(with-demoted-errors "nnrss: Failed to fetch: %S"
|
||||
(mm-url-insert url)))
|
||||
|
||||
(defun nnrss-decode-entities-string (string)
|
||||
(if string
|
||||
|
|
|
|||
|
|
@ -7715,19 +7715,13 @@ lines rather than by display lines."
|
|||
(declare (interactive-only forward-line))
|
||||
(interactive "^p\np")
|
||||
(or arg (setq arg 1))
|
||||
(if (and next-line-add-newlines (= arg 1))
|
||||
(if (save-excursion (end-of-line) (eobp))
|
||||
;; When adding a newline, don't expand an abbrev.
|
||||
(let ((abbrev-mode nil))
|
||||
(end-of-line)
|
||||
(insert (if use-hard-newlines hard-newline "\n")))
|
||||
(line-move arg nil nil try-vscroll))
|
||||
(if (called-interactively-p 'interactive)
|
||||
(condition-case err
|
||||
(line-move arg nil nil try-vscroll)
|
||||
((beginning-of-buffer end-of-buffer)
|
||||
(signal (car err) (cdr err))))
|
||||
(line-move arg nil nil try-vscroll)))
|
||||
(if (and next-line-add-newlines (= arg 1)
|
||||
(save-excursion (end-of-line) (eobp)))
|
||||
;; When adding a newline, don't expand an abbrev.
|
||||
(let ((abbrev-mode nil))
|
||||
(end-of-line)
|
||||
(insert (if use-hard-newlines hard-newline "\n")))
|
||||
(line-move arg nil nil try-vscroll))
|
||||
nil)
|
||||
|
||||
(defun previous-line (&optional arg try-vscroll)
|
||||
|
|
@ -7760,12 +7754,7 @@ lines rather than by display lines."
|
|||
"use `forward-line' with negative argument instead."))
|
||||
(interactive "^p\np")
|
||||
(or arg (setq arg 1))
|
||||
(if (called-interactively-p 'interactive)
|
||||
(condition-case err
|
||||
(line-move (- arg) nil nil try-vscroll)
|
||||
((beginning-of-buffer end-of-buffer)
|
||||
(signal (car err) (cdr err))))
|
||||
(line-move (- arg) nil nil try-vscroll))
|
||||
(line-move (- arg) nil nil try-vscroll)
|
||||
nil)
|
||||
|
||||
(defcustom track-eol nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue