Add more error reporting when nnimap fails early.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 25 Sep 2010 22:34:55 +0000 (00:34 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 25 Sep 2010 22:34:55 +0000 (00:34 +0200)
lisp/ChangeLog
lisp/nnimap.el

index 82b1b6e..53c3ab2 100644 (file)
@@ -1,5 +1,8 @@
 2010-09-25  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * nnimap.el (nnimap-open-connection): Add more error reporting when
+       nnimap fails early.
+
        * nnheader.el (nnheader-get-report-string): New function.
        (nnheader-get-report): Use it.
 
index cb378ec..353003d 100644 (file)
@@ -271,42 +271,50 @@ some servers.")
   (with-current-buffer (nnimap-make-process-buffer buffer)
     (let* ((coding-system-for-read 'binary)
           (coding-system-for-write 'binary)
+          (port nil)
           (ports
            (cond
             ((eq nnimap-stream 'network)
              (open-network-stream
               "*nnimap*" (current-buffer) nnimap-address
-              (or nnimap-server-port
-                  (if (netrc-find-service-number "imap")
-                      "imap"
-                    "143")))
+              (setq port
+                    (or nnimap-server-port
+                        (if (netrc-find-service-number "imap")
+                            "imap"
+                          "143"))))
              '("143" "imap"))
             ((eq nnimap-stream 'shell)
              (nnimap-open-shell-stream
               "*nnimap*" (current-buffer) nnimap-address
-              (or nnimap-server-port "imap"))
+              (setq port (or nnimap-server-port "imap")))
              '("imap"))
             ((eq nnimap-stream 'starttls)
              (starttls-open-stream
               "*nnimap*" (current-buffer) nnimap-address
-              (or nnimap-server-port "imap"))
+              (setq port (or nnimap-server-port "imap")))
              '("imap"))
             ((eq nnimap-stream 'ssl)
              (open-tls-stream
               "*nnimap*" (current-buffer) nnimap-address
-              (or nnimap-server-port
-                  (if (netrc-find-service-number "imaps")
-                      "imaps"
-                    "993")))
+              (setq port
+                    (or nnimap-server-port
+                        (if (netrc-find-service-number "imaps")
+                            "imaps"
+                          "993"))))
              '("143" "993" "imap" "imaps"))))
           connection-result login-result credentials)
       (setf (nnimap-process nnimap-object)
            (get-buffer-process (current-buffer)))
-      (when (and (nnimap-process nnimap-object)
-                (memq (process-status (nnimap-process nnimap-object))
-                      '(open run)))
+      (if (not (and (nnimap-process nnimap-object)
+                   (memq (process-status (nnimap-process nnimap-object))
+                         '(open run))))
+         (nnheader-report 'nnimap "Unable to contact %s:%s via %s"
+                          nnimap-address port nnimap-stream)
        (gnus-set-process-query-on-exit-flag (nnimap-process nnimap-object) nil)
-       (when (setq connection-result (nnimap-wait-for-connection))
+       (if (not (setq connection-result (nnimap-wait-for-connection)))
+           (nnheader-report 'nnimap
+                            "%s" (buffer-substring
+                                  (point) (line-end-position)))
          (when (eq nnimap-stream 'starttls)
            (nnimap-command "STARTTLS")
            (starttls-negotiate (nnimap-process nnimap-object)))