This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH setup 2/4] Don't show FTP 550 'file not found' errors in a MessageBox


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.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 nio-ie5.cc | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/nio-ie5.cc b/nio-ie5.cc
index 8786774..f5ad020 100644
--- a/nio-ie5.cc
+++ b/nio-ie5.cc
@@ -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;
         }
     }
 
-- 
2.17.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]