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 324919 823e118b3fad7539b0fc64202535ed3cbde2c634
parent 324918 84e97301a8c94aaa7279c624576983f3f3cac60f
child 324920 b3ea1334c33a48a50c21daf6150cf51651b1d16f
push id84550
push usergeorg.fritzsche@googlemail.com
push dateThu, 01 Dec 2016 13:57:49 +0000
treeherdermozilla-inbound@2c711bb8e373 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdexter
bugs1316281
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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) {