Bug 1499835 - do not needlessly assert in nsMsgProtocol::ShowAlertMessage() when TB is offline as this is no error situation. r=mkmelin
authoraceman <acelists@atlas.sk>
Mon, 22 Oct 2018 16:49:00 +0200
changeset 32685 a341cb829498f62cfad5e025a35a3a99bfae44d2
parent 32684 70d015af106d77ade34751ecb26fb538291d8699
child 32686 bfbeab417a162552a710aa103f3e214587c6e515
push id2343
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:37:21 +0000
treeherdercomm-beta@a0750c375f71 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1499835
Bug 1499835 - do not needlessly assert in nsMsgProtocol::ShowAlertMessage() when TB is offline as this is no error situation. r=mkmelin
mailnews/base/util/nsMsgProtocol.cpp
--- a/mailnews/base/util/nsMsgProtocol.cpp
+++ b/mailnews/base/util/nsMsgProtocol.cpp
@@ -36,16 +36,17 @@
 #include "nsIAsyncInputStream.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsIInputStreamPump.h"
 #include "nsICancelable.h"
 #include "nsMimeTypes.h"
 #include "mozilla/Services.h"
 #include "mozilla/SlicedInputStream.h"
 #include "nsContentSecurityManager.h"
+#include "nsPrintfCString.h"
 
 #undef PostMessage // avoid to collision with WinUser.h
 
 using namespace mozilla;
 
 NS_IMPL_ISUPPORTS(nsMsgProtocol, nsIChannel, nsIStreamListener,
   nsIRequestObserver, nsIRequest, nsITransportEventSink)
 
@@ -348,38 +349,39 @@ void nsMsgProtocol::ShowAlertMessage(nsI
      errorString = u"netTimeoutError";
      break;
   case NS_ERROR_NET_RESET:
      errorString = u"netResetError";
      break;
   case NS_ERROR_NET_INTERRUPT:
      errorString = u"netInterruptError";
      break;
+  case NS_ERROR_OFFLINE:
+     // Don't alert when offline as that is already displayed in the UI.
+     return;
   default:
-     // Leave the string as nullptr.
-     break;
+     nsPrintfCString msg("Unexpected status passed to ShowAlertMessage: %" PRIx32,
+                         static_cast<uint32_t>(aStatus));
+     NS_WARNING(msg.get());
+     return;
   }
 
-  NS_ASSERTION(errorString, "unknown error, but don't alert user.");
-  if (errorString)
+  nsString errorMsg;
+  errorMsg.Adopt(FormatStringWithHostNameByName(errorString, aMsgUrl));
+  if (errorMsg.IsEmpty())
   {
-    nsString errorMsg;
-    errorMsg.Adopt(FormatStringWithHostNameByName(errorString, aMsgUrl));
-    if (errorMsg.IsEmpty())
-    {
-      errorMsg.AssignLiteral(u"[StringID ");
-      errorMsg.Append(errorString);
-      errorMsg.AppendLiteral(u"?]");
-    }
+    errorMsg.AssignLiteral(u"[StringID ");
+    errorMsg.Append(errorString);
+    errorMsg.AppendLiteral(u"?]");
+  }
 
-    nsCOMPtr<nsIMsgMailSession> mailSession =
-      do_GetService(NS_MSGMAILSESSION_CONTRACTID);
-    if (mailSession)
-      mailSession->AlertUser(errorMsg, aMsgUrl);
-  }
+  nsCOMPtr<nsIMsgMailSession> mailSession =
+    do_GetService(NS_MSGMAILSESSION_CONTRACTID);
+  if (mailSession)
+    mailSession->AlertUser(errorMsg, aMsgUrl);
 }
 
 // stop binding is a "notification" informing us that the stream associated with aURL is going away.
 NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult aStatus)
 {
   nsresult rv = NS_OK;
 
   // if we are set up as a channel, we should notify our channel listener that we are starting...