fix(cli): straight: regurgitate type errors as connection errors

See included comment for explanation.
This commit is contained in:
Henrik Lissner 2024-03-26 22:58:56 -04:00
parent c0c52f0f61
commit d5bad5b430
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -799,5 +799,31 @@ However, in batch mode, print to stdout instead of stderr."
"/dev/null"))) "/dev/null")))
(apply fn args))) (apply fn args)))
;; If the repo failed to clone correctly (usually due to a connection failure),
;; straight proceeds as normal until a later call produces a garbage result
;; (typically, when it fails to fetch the remote branch of the empty directory).
;; This causes Straight to throw an otherwise cryptic type error when it tries
;; to sanitize the result for its log buffer.
;;
;; This error is a common source of user confusion and false positive bug
;; reports, so this advice catches them to regurgitates a more cogent
;; explanation.
(defadvice! doom-cli--straight-throw-error-on-no-branch-a (fn &rest args)
:around #'straight--process-log
(letf! ((defun shell-quote-argument (arg &optional posix)
(when (null arg)
(error "Package was not properly cloned due to a connection failure, please try again later"))
(funcall shell-quote-argument arg posix)))
(apply fn args)))
(defadvice! doom-cli--straight-regurgitate-empty-string-error-a (fn &rest args)
:around #'straight-vc-git-local-repo-name
(condition-case-unless-debug e
(apply fn args)
(wrong-type-argument
(if (eq (cadr e) 'stringp)
(error "Package was not properly cloned due to a connection failure, please try again later")
(signal (car e) (cdr e))))))
(provide 'doom-cli-packages) (provide 'doom-cli-packages)
;;; packages.el ends here ;;; packages.el ends here