Bug 1316281 - Part 1 - Improve error message for unknown events. r=dexter
☠☠ backed out by dd01d903f823 ☠ ☠
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Thu, 01 Dec 2016 14:57:32 +0100
changeset 325011 823e118b3fad7539b0fc64202535ed3cbde2c634
parent 325010 84e97301a8c94aaa7279c624576983f3f3cac60f
child 325012 b3ea1334c33a48a50c21daf6150cf51651b1d16f
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersdexter
bugs1316281
milestone53.0a1
Bug 1316281 - Part 1 - Improve error message for unknown events. r=dexter
toolkit/components/telemetry/TelemetryEvent.cpp
toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js
--- a/toolkit/components/telemetry/TelemetryEvent.cpp
+++ b/toolkit/components/telemetry/TelemetryEvent.cpp
@@ -514,19 +514,23 @@ TelemetryEvent::RecordEvent(const nsACSt
       return NS_ERROR_FAILURE;
     }
 
     res = ::RecordEvent(lock, timestamp, aCategory, aMethod, aObject, value, extra);
   }
 
   // Trigger warnings or errors where needed.
   switch (res) {
-    case RecordEventResult::UnknownEvent:
-      JS_ReportErrorASCII(cx, "Unknown event.");
+    case RecordEventResult::UnknownEvent: {
+      JS_ReportErrorASCII(cx, R"(Unknown event: ["%s", "%s", "%s"])",
+                          PromiseFlatCString(aCategory).get(),
+                          PromiseFlatCString(aMethod).get(),
+                          PromiseFlatCString(aObject).get());
       return NS_ERROR_INVALID_ARG;
+    }
     case RecordEventResult::InvalidExtraKey:
       LogToBrowserConsole(nsIScriptError::warningFlag,
                           NS_LITERAL_STRING("Invalid extra key for event."));
       return NS_OK;
     case RecordEventResult::StorageLimitReached:
       LogToBrowserConsole(nsIScriptError::warningFlag,
                           NS_LITERAL_STRING("Event storage limit reached."));
       return NS_OK;
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEvents.js
@@ -69,23 +69,23 @@ add_task(function* test_recording() {
     let e = entry.event;
     while ((e.length >= 3) && (e[e.length - 1] === null)) {
       e.pop();
     }
   }
 
   // The following should not result in any recorded events.
   Assert.throws(() => Telemetry.recordEvent("unknown.category", "test1", "object1"),
-                /Error: Unknown event\./,
+                /Error: Unknown event: \["unknown.category", "test1", "object1"\]/,
                 "Should throw on unknown category.");
   Assert.throws(() => Telemetry.recordEvent("telemetry.test", "unknown", "object1"),
-                /Error: Unknown event\./,
+                /Error: Unknown event: \["telemetry.test", "unknown", "object1"\]/,
                 "Should throw on unknown method.");
   Assert.throws(() => Telemetry.recordEvent("telemetry.test", "test1", "unknown"),
-                /Error: Unknown event\./,
+                /Error: Unknown event: \["telemetry.test", "test1", "unknown"\]/,
                 "Should throw on unknown object.");
 
   let checkEvents = (events, expectedEvents) => {
     checkEventFormat(events);
     Assert.equal(events.length, expectedEvents.length,
                  "Snapshot should have the right number of events.");
 
     for (let i = 0; i < events.length; ++i) {