emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/opam-switch-mode eaf04b959d 25/31: fix: Improve error hand


From: ELPA Syncer
Subject: [nongnu] elpa/opam-switch-mode eaf04b959d 25/31: fix: Improve error handling further (if opam can't be found)
Date: Mon, 14 Nov 2022 09:00:01 -0500 (EST)

branch: elpa/opam-switch-mode
commit eaf04b959dcb01aea32d6d76aebfec568c50b963
Author: Erik Martin-Dorel <erik.martin-dorel@irit.fr>
Commit: Erik Martin-Dorel <erik.martin-dorel@irit.fr>

    fix: Improve error handling further (if opam can't be found)
---
 opam-switch-mode.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/opam-switch-mode.el b/opam-switch-mode.el
index 871c3dfd56..1f8379c8f6 100644
--- a/opam-switch-mode.el
+++ b/opam-switch-mode.el
@@ -135,7 +135,8 @@ This function  `opam-switch--run-command-without-stderr'."
 
 (defun opam-switch--get-root ()
   "Get the opam root directory.
-This is the opam variable 'root'."
+This function gets the opam variable 'root'.
+This function should not be called directly; see `opam-switch--root'."
   (let ((root (opam-switch--command-as-string "var" nil nil "root")))
     (unless root
       (error "Command 'opam var root' failed"))
@@ -152,7 +153,7 @@ This is the opam variable 'root'."
       (let ((result
              (condition-case _sig
                  (opam-switch--get-root)
-               (file-missing (message "Can't set (opam-switch--root); is opam 
installed?") nil))))
+               (file-missing (error "Cannot run opam") nil))))
         (when result
           (setq opam-switch--root result)))))
 
@@ -352,9 +353,12 @@ The mode can be enabled only if opam is found and 'opam 
var root' succeeds."
   :keymap opam-switch--mode-keymap
   :group 'opam-switch
   (when opam-switch-mode
-    (if (opam-switch--root)
-        (opam-switch--setup-opam-switch-mode)
-      (setq opam-switch-mode nil))))
+    (condition-case sig
+        (progn
+          (opam-switch--root)
+          (opam-switch--setup-opam-switch-mode))
+      (t (setq opam-switch-mode nil)
+         (message "Opam-Switch mode disabled %s" (pp-to-string sig))))))
 
 (provide 'opam-switch-mode)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]