erc-commit
[Top][All Lists]
Advanced

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

[Erc-commit] [commit][emacs22] Display message or trigger error dependin


From: mwolson
Subject: [Erc-commit] [commit][emacs22] Display message or trigger error depending on debug-on-error
Date: Sun, 14 Oct 2007 00:49:05 -0400

commit ddcd521e176efb3ea9fb18a8b8dc121cec7757f6
Author: Michael Olson <address@hidden>
Date:   Fri Jul 13 02:33:55 2007 +0000

    Display message or trigger error depending on debug-on-error
    
    2007-07-13  Michael Olson  <address@hidden>
    
        * erc-goodies.el (erc-get-bg-color-face, erc-get-fg-color-face):
        Use erc-error rather than message and beep.
    
        * erc-sound.el: Indentation fix.
    
        * erc.el (erc-error): New function that either displays a message
        or throws an error, depending on whether debug-on-error is
        non-nil.
        (erc-cmd-SERVER, erc-send-current-line): Use it.
    git-archimport-id: address@hidden/erc--main--0--patch-158

diff --git a/ChangeLog b/ChangeLog
index 379d66b..7480e79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2007-07-13  Michael Olson  <address@hidden>
 
+       * erc-goodies.el (erc-get-bg-color-face, erc-get-fg-color-face):
+       Use erc-error rather than message and beep.
+
+       * erc-sound.el: Indentation fix.
+
        * erc.el (erc-command-no-process-p): New function that determines
        if its argument is an ERC command that can be run when the server
        process is not alive.
@@ -10,6 +15,9 @@
        (erc-send-current-line): Call erc-command-no-process-p if the
        server process is not alive, to determine if we have a command
        that can be run anyway.  Thanks to Tom Tromey for the bug report.
+       (erc-error): New function that either displays a message or throws
+       an error, depending on whether debug-on-error is non-nil.
+       (erc-cmd-SERVER, erc-send-current-line): Use it.
 
 2007-07-10  Michael Olson  <address@hidden>
 
diff --git a/erc-goodies.el b/erc-goodies.el
index 064c742..c92c33d 100644
--- a/erc-goodies.el
+++ b/erc-goodies.el
@@ -281,10 +281,8 @@ The value `erc-interpret-controls-p' must also be t for 
this to work."
   "Fetches the right face for background color N (0-15)."
   (if (stringp n) (setq n (string-to-number n)))
   (if (not (numberp n))
-      (progn
-        (message "erc-get-bg-color-face: n is NaN: %S" n)
-        (beep)
-        'default)
+      (prog1 'default
+        (erc-error "erc-get-bg-color-face: n is NaN: %S" n))
     (when (> n 16)
       (erc-log (format "   Wrong color: %s" n))
       (setq n (mod n 16)))
@@ -297,10 +295,8 @@ The value `erc-interpret-controls-p' must also be t for 
this to work."
   "Fetches the right face for foreground color N (0-15)."
   (if (stringp n) (setq n (string-to-number n)))
   (if (not (numberp n))
-      (progn
-        (message "erc-get-fg-color-face: n is NaN: %S" n)
-        (beep)
-        'default)
+      (prog1 'default
+        (erc-error "erc-get-fg-color-face: n is NaN: %S" n))
     (when (> n 16)
       (erc-log (format "   Wrong color: %s" n))
       (setq n (mod n 16)))
diff --git a/erc-sound.el b/erc-sound.el
index 4d3d792..d02887a 100644
--- a/erc-sound.el
+++ b/erc-sound.el
@@ -125,7 +125,7 @@ See also `play-sound-file'."
     (if (and (not filepath) erc-default-sound)
        (setq filepath erc-default-sound))
     (cond ((and filepath (file-exists-p filepath))
-           (play-sound-file filepath))
+          (play-sound-file filepath))
          (t (beep)))
     (erc-log (format "Playing sound file %S" filepath))))
 
@@ -142,5 +142,11 @@ See also `play-sound-file'."
 
 (provide 'erc-sound)
 
-;; arch-tag: 53657d1d-007f-4a20-91c1-588e71cf0cee
 ;;; erc-sound.el ends here
+;;
+;; Local Variables:
+;; indent-tabs-mode: t
+;; tab-width: 8
+;; End:
+
+;; arch-tag: 53657d1d-007f-4a20-91c1-588e71cf0cee
diff --git a/erc.el b/erc.el
index 9fcf119..324a820 100644
--- a/erc.el
+++ b/erc.el
@@ -2189,6 +2189,17 @@ BUFFER.  HOST and PORT specify the connection target."
                 nil))
     (open-tls-stream name buffer host port)))
 
+;;; Displaying error messages
+
+(defun erc-error (&rest args)
+  "Pass ARGS to `format', and display the result as an error message.
+If `debug-on-error' is set to non-nil, then throw a real error with this
+message instead, to make debugging easier."
+  (if debug-on-error
+      (apply #'error args)
+    (apply #'message args)
+    (beep)))
+
 ;;; Debugging the protocol
 
 (defvar erc-debug-irc-protocol nil
@@ -3264,8 +3275,7 @@ the message given by REASON."
   (condition-case nil
       (erc :server server :nick (erc-current-nick))
     (error
-     (message "Cannot find host %s." server)
-     (beep)))
+     (erc-error "Cannot find host %s." server)))
   t)
 (put 'erc-cmd-SERVER 'process-not-needed t)
 
@@ -4965,17 +4975,13 @@ Specifically, return the position of 
`erc-insert-marker'."
   (save-restriction
     (widen)
     (if (< (point) (erc-beg-of-input-line))
-       (progn
-         (message "Point is not in the input area")
-         (beep))
+       (erc-error "Point is not in the input area")
       (let ((inhibit-read-only t)
            (str (erc-user-input))
            (old-buf (current-buffer)))
        (if (and (not (erc-server-buffer-live-p))
                 (not (erc-command-no-process-p str)))
-           (progn
-             (message "ERC: No process running")
-             (beep))
+           (erc-error "ERC: No process running")
          (erc-set-active-buffer (current-buffer))
 
          ;; Kill the input and the prompt




reply via email to

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