]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
Don't show FTP 550 'file not found' errors in a MessageBox
authorJon Turney <jon.turney@dronecode.org.uk>
Wed, 20 Mar 2019 17:12:08 +0000 (17:12 +0000)
committerJon Turney <jon.turney@dronecode.org.uk>
Wed, 20 Mar 2019 17:35:20 +0000 (17:35 +0000)
Don't show FTP 550 'file not found' errors in a MessageBox. Also log
InternetGetLastResponseInfo() when fetching a URL.

WinInet documentation seems to indicate this kind of extended error
information only exists when WinInet has an FTP error code to report.

Log this error (and the associated URL) rather than just showing a
MessageBox. Don't bother showing a MessageBox for 550, since we can
tolerate certain missing files (e.g. setup.zst), and we'll go on to
report that couldn't fetch needed files in a more generic way.

nio-ie5.cc

index 8786774bd0a28581b7fbbae95b3f43e6d09cf441..f5ad020c351674f5463a291c635fe8aa62069c17 100644 (file)
@@ -216,15 +216,24 @@ try_again:
     {
       DWORD e = GetLastError ();
       if (e == ERROR_INTERNET_EXTENDED_ERROR)
-       {
-         char buf[2000];
-         DWORD e, l = sizeof (buf);
-         InternetGetLastResponseInfo (&e, buf, &l);
-         mbox (0, buf, "Internet Error", MB_OK);
-       }
+        {
+          char buf[2000];
+          DWORD e, l = sizeof (buf);
+          InternetGetLastResponseInfo (&e, buf, &l);
+
+          // show errors apart from file-not-found (e doesn't contain the
+          // response code so we have to resort to looking at the message)
+          if (strncmp("550", buf, 3) != 0)
+            mbox (0, buf, "Internet Error", MB_OK);
+
+          for (unsigned int i = 0; i < l; i++)
+            if (buf[i] == '\n' or buf[i] == '\r')
+              buf[i] = ' ';
+          Log (LOG_PLAIN) << "connection error: " << buf << " fetching " << url << endLog;
+        }
       else
         {
-          Log (LOG_PLAIN) << "connection error: " << e << endLog;
+          Log (LOG_PLAIN) << "connection error: " << e << " fetching " << url << endLog;
         }
     }
 
This page took 0.03552 seconds and 5 git commands to generate.