Skip to content

Commit

Permalink
Switching from debugger hook to just condition-case.
Browse files Browse the repository at this point in the history
The motivation for using debugger was to get a backtrace, but this is more
complicated than originally thought.

* `signal-hook-function' does not not work because it gets every signal,
  even ones that would be handled by `condition-case'.
* `debugger' and `debug-on-error' because the debugger will only be invoked
  once per event.
  • Loading branch information
chaosemer committed Dec 12, 2023
1 parent fa7ada3 commit ea9f131
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions init-dir.el
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,15 @@ FILE: File path to a file to load. Unlike `load', this must be
an absolute path with an extension.
ROOT-DIR: Directory root being loaded from."
(let ((prev-time (time-convert nil 'list))
(debug-ignored-errors '())
(debug-on-error t)
(debugger #'init-dir--debugger)
;; Dynamic binding intended to be modified by clients.
(init-dir--long-load-time-warning init-dir--long-load-time-warning))

(let* (;; This line actually loads the file as a side effect.
(load-error (catch 'init-dir--load-error
(load file nil nil t t)
nil))

(load-error
(condition-case err
(load file nil nil t t)
(:success nil)
((debug t) err)))
(cur-time (time-convert nil 'list))
(delta-time (float-time (time-subtract cur-time prev-time))))
(when load-error
Expand Down Expand Up @@ -195,16 +193,6 @@ ROOT-DIR: Directory root that file is in."
(throw 'return file-with-suffix))))
nil))

(defun init-dir--debugger (&rest args)
"Replacement debugger function while running `init-dir--load-single-file'.
ARGS: See `debugger' for the meaning of ARGS."
(if (eq (car-safe args) 'error)
;; This entered the debugger due to an error -- the exact case
;; we want to handle specially.
(throw 'init-dir--load-error (car-safe (cdr-safe args)))
(apply #'debug args)))

(provide 'init-dir)

;;; init-dir.el ends here

0 comments on commit ea9f131

Please sign in to comment.