* nntp.el (nntp-send-command-and-decode): Check PROCESS.
[gnus] / lisp / nntp.el
index 3a0265b..6c4b226 100644 (file)
@@ -434,22 +434,26 @@ noticing asynchronous data.")
       (set-buffer nntp-server-buffer)
       (erase-buffer)))
   (let* ((command (mapconcat 'identity strings " "))
-        (buffer (process-buffer (nntp-find-connection nntp-server-buffer)))
-        (pos (with-current-buffer buffer (point))))
-    (prog1
-       (nntp-retrieve-data command
-                           nntp-address nntp-port-number nntp-server-buffer
-                           wait-for nnheader-callback-function t)
-      ;; If nothing to wait for, still remove possibly echo'ed commands
-      (unless wait-for
-       (nntp-accept-response)
-       (save-excursion
+        (process (nntp-find-connection nntp-server-buffer))
+        (buffer (and process (process-buffer process)))
+        (pos (and buffer (with-current-buffer buffer (point)))))
+    (if process
+       (prog1
+           (nntp-retrieve-data command
+                               nntp-address nntp-port-number 
+                               nntp-server-buffer
+                               wait-for nnheader-callback-function t)
+         ;; If nothing to wait for, still remove possibly echo'ed commands
+         (unless wait-for
+           (nntp-accept-response)
+           (save-excursion
          (set-buffer buffer)
          (goto-char pos)
          (if (looking-at (regexp-quote command))
              (delete-region pos (progn (forward-line 1) (gnus-point-at-bol))))
          )))
-    ))
+      (nnheader-report 'nntp "Couldn't open connection to %s."
+                      nntp-address))))
 
 
 (defun nntp-send-buffer (wait-for)