Redesign Doom error handling

Another refactor, again to improve the locality of doom errors and make
the data that accompanies them more useful in determining the origin and
source of issues. Also, bin/doom is now a little more informative about
how to debug errors.
This commit is contained in:
Henrik Lissner 2018-06-20 02:07:12 +02:00
parent 84756b33a0
commit 151858a8dc
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
5 changed files with 89 additions and 64 deletions

View file

@ -463,10 +463,22 @@ If NOERROR is non-nil, don't throw an error if the file doesn't exist."
(setq path (or (DIR!)
(error "Could not detect path to look for '%s' in"
filename))))
`(load ,(if path
`(expand-file-name ,filename ,path)
filename)
,noerror ,(not doom-debug-mode)))
(let ((file (if path `(expand-file-name ,filename ,path) filename)))
`(condition-case e
(load ,file ,noerror ,(not doom-debug-mode))
((debug doom-error) (signal (car e) (cdr e)))
((debug error)
(let* ((source (file-name-sans-extension ,file))
(err (cond ((file-in-directory-p source doom-core-dir)
(cons 'doom-error doom-core-dir))
((file-in-directory-p source doom-private-dir)
(cons 'doom-private-error doom-private-dir))
((cons 'doom-module-error doom-emacs-dir)))))
(signal (car err)
(list (file-relative-name
(concat source ".el")
(cdr err))
e)))))))
(provide 'core-lib)
;;; core-lib.el ends here