refactor(cli): throw error if Doom fails to load

This commit is contained in:
Henrik Lissner 2022-09-10 14:14:39 +02:00
parent 3505e666a8
commit c747d218ae
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -74,13 +74,17 @@
;; - The user may have a noexec flag set on /tmp, so pass the exit script to ;; - The user may have a noexec flag set on /tmp, so pass the exit script to
;; /bin/sh rather than executing them directly. ;; /bin/sh rather than executing them directly.
;; In CLI sessions, prefer correctness over performance.
(setq load-prefer-newer t)
;; Doom's core sets up everything we need; including `doom-*-dir' variables, ;; Doom's core sets up everything we need; including `doom-*-dir' variables,
;; universal defaults, and autoloads for doom-*-initialize functions. ;; universal defaults, and autoloads for doom-*-initialize functions.
(condition-case e (condition-case e
(let ((load-prefer-newer t)) (let* ((bin-dir (file-name-directory (file-truename load-file-name)))
(load (expand-file-name (init-file (expand-file-name "../early-init.el" bin-dir)))
"../early-init" (file-name-directory (file-truename load-file-name))) (or (and (load init-file nil 'nomessage)
nil 'nomessage)) (featurep 'doom))
(user-error "Failed to load Doom from %s" init-file)))
;; Prevent ugly backtraces for trivial errors ;; Prevent ugly backtraces for trivial errors
(user-error (message "Error: %s" (cadr e)) (user-error (message "Error: %s" (cadr e))
(kill-emacs 2))) (kill-emacs 2)))