Subject: bug#53762: Improve error message when during url retrieving network connection is lost

From: Robert Pluim <[email-masked]>
Date: Fri, 04 Feb 2022 10:50:41 +0100

>>>>> On Thu, 03 Feb 2022 19:30:31 +0000, emacsq via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]> said:

    emacsq> Sometimes when fetching an URL with url-retireve emacs
    emacsq> returns the error "Process <URL> not running"

    emacsq> This is the case when emacs tries to do an operation
    emacsq> on the process and finds the process is not running anymore.

    emacsq> In case of fetching an url it is presumably because of
    emacsq> the network connection is unexpectedly lost, so for network
    emacsq> processes returning an error message like "Network connection
    emacsq> closed unexpectedly" or similar is more informative for the
    emacsq> user than saying "Process X not running".

Does something like this do the trick? Iʼve not been able to get a
reliable test case for it yet.

diff --git a/src/process.c b/src/process.c
index 7c7f608284..18d4579dba 100644
--- a/src/process.c
+++ b/src/process.c
@@ -6424,7 +6424,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
   if (p->raw_status_new)
     update_status (p);
   if (! EQ (p->status, Qrun))
-    error ("Process %s not running", SDATA (p->name));
+    error ("Process %s %s", SDATA (p->name), SDATA (status_message (p)));
   if (p->outfd < 0)
     error ("Output file descriptor of %s is closed", SDATA (p->name));
 
@@ -7129,7 +7129,7 @@ DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0,
   if (XPROCESS (proc)->raw_status_new)
     update_status (XPROCESS (proc));
   if (! EQ (XPROCESS (proc)->status, Qrun))
-    error ("Process %s not running", SDATA (XPROCESS (proc)->name));
+    error ("Process %s %s", SDATA (XPROCESS (proc)->name), SDATA (status_message (XPROCESS (proc))));
 
   if (coding && CODING_REQUIRE_FLUSHING (coding))
     {