Bug 855847 - Fix misleading console warning. r=yoric
authorTareq Khandaker <tareqakhandaker@gmail.com>
Fri, 04 Oct 2013 13:16:53 -0400
changeset 149913 faf5a0c01118c15106a25caad309ecb3328bfdd3
parent 149912 f239497c4d05d75a9d0d8f2b56b7d2ebf472e36a
child 149914 d9a7d1fcb34ca90dc6f4925890e818421270cdf5
push idunknown
push userunknown
push dateunknown
reviewersyoric
bugs855847
milestone27.0a1
Bug 855847 - Fix misleading console warning. r=yoric
xpcom/base/nsConsoleService.cpp
--- a/xpcom/base/nsConsoleService.cpp
+++ b/xpcom/base/nsConsoleService.cpp
@@ -13,16 +13,17 @@
 #include "nsMemory.h"
 #include "nsCOMArray.h"
 #include "nsThreadUtils.h"
 
 #include "nsConsoleService.h"
 #include "nsConsoleMessage.h"
 #include "nsIClassInfoImpl.h"
 #include "nsIConsoleListener.h"
+#include "nsPrintfCString.h"
 
 #include "mozilla/Preferences.h"
 
 #if defined(ANDROID)
 #include <android/log.h>
 #endif
 #ifdef XP_WIN
 #include <windows.h>
@@ -162,17 +163,22 @@ nsConsoleService::LogMessageWithMode(nsI
     if (message == nullptr)
         return NS_ERROR_INVALID_ARG;
 
     if (!sLoggingEnabled) {
         return NS_OK;
     }
 
     if (NS_IsMainThread() && mDeliveringMessage) {
-        NS_WARNING("Some console listener threw an error while inside itself. Discarding this message");
+        nsString msg;
+        message->GetMessageMoz(getter_Copies(msg));
+        NS_WARNING(nsPrintfCString("Reentrancy error: some client attempted "
+            "to display a message to the console while in a console listener. "
+            "The following message was discarded: \"%s\"",
+            NS_ConvertUTF16toUTF8(msg).get()).get());
         return NS_ERROR_FAILURE;
     }
 
     nsRefPtr<LogMessageRunnable> r;
     nsIConsoleMessage *retiredMessage;
 
     if (sLoggingBuffered) {
         NS_ADDREF(message); // early, in case it's same as replaced below.