mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
feat(lib): introduce doom-error & error functions
This commit is contained in:
@ -228,7 +228,6 @@ the return value of the executed CLI."
|
||||
;;
|
||||
;;; Errors
|
||||
|
||||
(define-error 'doom-cli-error "There was an unexpected error" 'doom-error)
|
||||
(define-error 'doom-cli-definition-error "Invalid CLI definition" 'doom-cli-error)
|
||||
(define-error 'doom-cli-autoload-error "Failed to autoload deferred command" 'doom-cli-error)
|
||||
(define-error 'doom-cli-invalid-prefix-error "Prefix has no defined commands" 'doom-cli-error)
|
||||
|
@ -4,16 +4,32 @@
|
||||
|
||||
;;; Custom error types
|
||||
(define-error 'doom-error "An unexpected Doom error")
|
||||
(define-error 'doom-font-error "Could not find a font on your system" 'doom-error)
|
||||
(define-error 'doom-nosync-error "Doom hasn't been initialized yet; did you remember to run 'doom sync' in the shell?" 'doom-error)
|
||||
(define-error 'doom-core-error "Unexpected error in Doom's core" 'doom-error)
|
||||
(define-error 'doom-context-error "Incorrect context error" 'doom-error)
|
||||
(define-error 'doom-hook-error "Error in a Doom startup hook" 'doom-error)
|
||||
(define-error 'doom-autoload-error "Error in Doom's autoloads file" 'doom-error)
|
||||
(define-error 'doom-user-error "Error caused by user's config or system" 'doom-error)
|
||||
(define-error 'doom-module-error "Error in a Doom module" 'doom-error)
|
||||
(define-error 'doom-package-error "Error with packages" 'doom-error)
|
||||
(define-error 'doom-profile-error "Error while processing profiles" 'doom-error)
|
||||
(dolist (type '((doom-font-error "Could not find a font on your system" doom-error)
|
||||
(doom-nosync-error "Doom hasn't been initialized yet; did you remember to run 'doom sync' in the shell?" doom-error)
|
||||
(doom-core-error "Unexpected error in Doom's core" doom-error)
|
||||
(doom-cli-error "Unexpected error in Doom's CLI" doom-error)
|
||||
(doom-context-error "Incorrect context error" doom-error)
|
||||
(doom-hook-error "Error in a Doom startup hook" doom-error)
|
||||
(doom-autoload-error "Error in Doom's autoloads file" doom-error)
|
||||
(doom-user-error "Error caused by user's config or system" doom-error)
|
||||
(doom-profile-error "Error while processing profiles" doom-error)
|
||||
(doom-module-error "Error in a Doom module" doom-profile-error)
|
||||
(doom-source-error "Error in a Doom source" doom-profile-error)
|
||||
(doom-package-error "Error with packages" doom-profile-error)))
|
||||
(apply #'define-error type)
|
||||
(fset (car type) (lambda (&rest data) (signal (car type) data))))
|
||||
|
||||
(defmacro doom-error (type &rest data)
|
||||
"Signal a Doom error of TYPE with DATA.
|
||||
|
||||
TYPE should be a keyword of any of the known doom-*-error errors (e.g. :font,
|
||||
:module, etc), or the name of any error."
|
||||
`(signal ,(if (keywordp type)
|
||||
`(quote
|
||||
,(or (intern-soft (format "doom-%s-error" (doom-keyword-name type)))
|
||||
(doom-core-error "Invalid error type" type)))
|
||||
type)
|
||||
(list ,@data)))
|
||||
|
||||
|
||||
;;
|
||||
|
Reference in New Issue
Block a user