branch: elpa/flymake-pyrefly commit 0c04d3b2d501d44a33efcd8e5b09335d3ebdeb03 Author: Boris Shminke <bo...@shminke.com> Commit: Boris Shminke <bo...@shminke.com>
raise custom error when there is no pyrefly installed --- flymake-pyrefly.el | 4 +++- tests/test-flymake-pyrefly.el | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/flymake-pyrefly.el b/flymake-pyrefly.el index 01982baedd..ed7a96aa28 100644 --- a/flymake-pyrefly.el +++ b/flymake-pyrefly.el @@ -39,12 +39,14 @@ (require 'cl-lib) (defvar-local pyrefly--flymake-proc nil) +(define-error 'no-pyrefly-error "Cannot find pyrefly") + (defun pyrefly-flymake-backend (report-fn &rest _args) "Report pyrefly diagnostic with REPORT-FN." ;; Not having pyrefly installed is a serious problem which should cause ;; the backend to disable itself, so an error is signaled. (unless (executable-find "pyrefly") - (error "Cannot find pyrefly")) + (signal 'no-pyrefly-error nil)) ;; If a live process launched in an earlier check was found, that ;; process is killed. When that process's sentinel eventually runs, diff --git a/tests/test-flymake-pyrefly.el b/tests/test-flymake-pyrefly.el index 170ddd70b0..9d7b487a7f 100644 --- a/tests/test-flymake-pyrefly.el +++ b/tests/test-flymake-pyrefly.el @@ -24,7 +24,8 @@ (ert-deftest flymake-pyrefly-test-no-pyrefly () "Test error message when Pyrefly is not found." (find-file "tests/example.py") - (should-error (pyrefly-flymake-backend 'identity))) + (should-error (pyrefly-flymake-backend 'identity) + :type 'no-pyrefly-error)) (ert-deftest flymake-pyrefly-test-normal-use-case () "Test a normal Pyrefly use-case." (defun mock-report-fn (args)