Skip to content

Commit a94fe03

Browse files
committed
Bug 1811334 - Automatically replace Cu.reportError with console.error (most of browser/components). r=settings-reviewers,mconley
Differential Revision: https://phabricator.services.mozilla.com/D167297
1 parent ac470c9 commit a94fe03

File tree

78 files changed

+284
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+284
-289
lines changed

.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,10 @@ module.exports = {
208208
// Bug 877389 - Gradually migrate from Cu.reportError to console.error.
209209
// Report as warnings where it is not yet passing.
210210
files: [
211-
"browser/components/**",
212211
"dom/push/test/mockpushserviceparent.js",
212+
"browser/components/extensions/**",
213213
"toolkit/**",
214214
],
215-
excludedFiles: ["browser/components/Browser*.*"],
216215
rules: {
217216
"mozilla/no-cu-reportError": "off",
218217
},

browser/components/customizableui/CustomizableUI.jsm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ var CustomizableUIInternal = {
22142214
try {
22152215
aWidget.onClick.call(null, aEvent);
22162216
} catch (e) {
2217-
Cu.reportError(e);
2217+
console.error(e);
22182218
}
22192219
} else {
22202220
// XXXunf Need to think this through more, and formalize.
@@ -2951,7 +2951,7 @@ var CustomizableUIInternal = {
29512951
}
29522952
},
29532953
err => {
2954-
Cu.reportError(err);
2954+
console.error(err);
29552955
}
29562956
);
29572957
}
@@ -3125,7 +3125,7 @@ var CustomizableUIInternal = {
31253125
aArgs
31263126
);
31273127
} catch (e) {
3128-
Cu.reportError(e);
3128+
console.error(e);
31293129
return undefined;
31303130
}
31313131
};

browser/components/customizableui/CustomizableWidgets.jsm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ if (Services.prefs.getBoolPref("privacy.panicButton.enabled")) {
572572
promise.then(function() {
573573
let otherWindow = Services.wm.getMostRecentWindow("navigator:browser");
574574
if (otherWindow.closed) {
575-
Cu.reportError("Got a closed window!");
575+
console.error("Got a closed window!");
576576
}
577577
if (otherWindow.PanicButtonNotifier) {
578578
otherWindow.PanicButtonNotifier.notify();

browser/components/customizableui/CustomizeMode.jsm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ CustomizeMode.prototype = {
10781078
try {
10791079
item = this.unwrapToolbarItem(aWrapper);
10801080
} catch (ex) {
1081-
Cu.reportError(ex);
1081+
console.error(ex);
10821082
}
10831083
resolve(item);
10841084
});

browser/components/customizableui/PanelMultiView.jsm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ var AssociatedToNode = class {
234234
// Any exception in the blocker will cancel the operation.
235235
blockers.add(
236236
promise.catch(ex => {
237-
Cu.reportError(ex);
237+
console.error(ex);
238238
return true;
239239
})
240240
);
@@ -253,7 +253,7 @@ var AssociatedToNode = class {
253253
]);
254254
cancel = cancel || results.some(result => result === false);
255255
} catch (ex) {
256-
Cu.reportError(
256+
console.error(
257257
new Error(`One of the blockers for ${eventName} timed out.`)
258258
);
259259
return true;
@@ -656,27 +656,27 @@ var PanelMultiView = class extends AssociatedToNode {
656656
* subview when a "title" attribute is not specified.
657657
*/
658658
showSubView(viewIdOrNode, anchor) {
659-
this._showSubView(viewIdOrNode, anchor).catch(Cu.reportError);
659+
this._showSubView(viewIdOrNode, anchor).catch(console.error);
660660
}
661661
async _showSubView(viewIdOrNode, anchor) {
662662
let viewNode =
663663
typeof viewIdOrNode == "string"
664664
? PanelMultiView.getViewNode(this.document, viewIdOrNode)
665665
: viewIdOrNode;
666666
if (!viewNode) {
667-
Cu.reportError(new Error(`Subview ${viewIdOrNode} doesn't exist.`));
667+
console.error(new Error(`Subview ${viewIdOrNode} doesn't exist.`));
668668
return;
669669
}
670670

671671
if (!this.openViews.length) {
672-
Cu.reportError(new Error(`Cannot show a subview in a closed panel.`));
672+
console.error(new Error(`Cannot show a subview in a closed panel.`));
673673
return;
674674
}
675675

676676
let prevPanelView = this.openViews[this.openViews.length - 1];
677677
let nextPanelView = PanelView.forNode(viewNode);
678678
if (this.openViews.includes(nextPanelView)) {
679-
Cu.reportError(new Error(`Subview ${viewNode.id} is already open.`));
679+
console.error(new Error(`Subview ${viewNode.id} is already open.`));
680680
return;
681681
}
682682

@@ -753,7 +753,7 @@ var PanelMultiView = class extends AssociatedToNode {
753753
* Navigates backwards by sliding out the most recent subview.
754754
*/
755755
goBack() {
756-
this._goBack().catch(Cu.reportError);
756+
this._goBack().catch(console.error);
757757
}
758758
async _goBack() {
759759
if (this.openViews.length < 2) {

browser/components/customizableui/content/panelUI.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ const PanelUI = {
228228
await PanelMultiView.openPopup(this.panel, anchor, {
229229
triggerEvent: domEvent,
230230
});
231-
})().catch(Cu.reportError);
231+
})().catch(console.error);
232232
},
233233

234234
/**
@@ -408,13 +408,14 @@ const PanelUI = {
408408

409409
let viewNode = PanelMultiView.getViewNode(document, aViewId);
410410
if (!viewNode) {
411-
Cu.reportError("Could not show panel subview with id: " + aViewId);
411+
console.error("Could not show panel subview with id: ", aViewId);
412412
return;
413413
}
414414

415415
if (!aAnchor) {
416-
Cu.reportError(
417-
"Expected an anchor when opening subview with id: " + aViewId
416+
console.error(
417+
"Expected an anchor when opening subview with id: ",
418+
aViewId
418419
);
419420
return;
420421
}
@@ -487,7 +488,7 @@ const PanelUI = {
487488
triggerEvent: aEvent,
488489
});
489490
} catch (ex) {
490-
Cu.reportError(ex);
491+
console.error(ex);
491492
}
492493

493494
if (viewShown) {

browser/components/customizableui/test/browser_877006_missing_view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ add_task(function testAddbrokenViewWidget() {
2020
CustomizableUI.createWidget(widgetSpec);
2121
CustomizableUI.addWidgetToArea(kWidgetId, CustomizableUI.AREA_NAVBAR);
2222
} catch (ex) {
23-
Cu.reportError(ex);
23+
console.error(ex);
2424
noError = false;
2525
}
2626
ok(
@@ -32,7 +32,7 @@ add_task(function testAddbrokenViewWidget() {
3232
try {
3333
CustomizableUI.destroyWidget(kWidgetId);
3434
} catch (ex) {
35-
Cu.reportError(ex);
35+
console.error(ex);
3636
noError = false;
3737
}
3838
ok(

browser/components/customizableui/test/browser_890262_destroyWidget_after_add_to_panel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ add_task(function() {
2121
try {
2222
CustomizableUI.destroyWidget(kWidget1Id);
2323
} catch (ex) {
24-
Cu.reportError(ex);
24+
console.error(ex);
2525
noError = false;
2626
}
2727
ok(
@@ -43,7 +43,7 @@ add_task(function() {
4343
try {
4444
CustomizableUI.destroyWidget(kWidget2Id);
4545
} catch (ex) {
46-
Cu.reportError(ex);
46+
console.error(ex);
4747
noError = false;
4848
}
4949
ok(

browser/components/customizableui/test/browser_892955_isWidgetRemovable_for_removed_widgets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ add_task(async function() {
2020
CustomizableUI.removeWidgetFromArea(kWidgetId);
2121
} catch (ex) {
2222
noError = false;
23-
Cu.reportError(ex);
23+
console.error(ex);
2424
}
2525
ok(noError, "Shouldn't throw an error removing a destroyed widget.");
2626
});

browser/components/customizableui/test/browser_952963_areaType_getter_no_area.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ registerCleanupFunction(() => {
1414
CustomizableUI.destroyWidget(kTestWidget);
1515
CustomizableUI.destroyWidget(kUnregisterAreaTestWidget);
1616
} catch (ex) {
17-
Cu.reportError(ex);
17+
console.error(ex);
1818
}
1919
});
2020

browser/components/customizableui/test/browser_956602_remove_special_widget.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ add_task(async function() {
2525
"No separator in the palette."
2626
);
2727
} catch (ex) {
28-
Cu.reportError(ex);
28+
console.error(ex);
2929
ok(false, "Shouldn't throw an exception moving an item to the navbar.");
3030
} finally {
3131
await endCustomizing();

browser/components/customizableui/test/browser_980155_add_overflow_toolbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ add_task(async function addOverflowingToolbar() {
1717
CustomizableUI.destroyWidget(id);
1818
}
1919
} catch (ex) {
20-
Cu.reportError(ex);
20+
console.error(ex);
2121
}
2222
});
2323

browser/components/distribution.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ DistributionCustomizer.prototype = {
9393
Services.prefs.clearUserPref(PREF_CACHED_FILE_EXISTENCE);
9494
} else {
9595
// Unable to parse INI.
96-
Cu.reportError("Unable to parse distribution.ini");
96+
console.error("Unable to parse distribution.ini");
9797
}
9898
}
9999
this.__defineGetter__("_ini", () => ini);
@@ -264,7 +264,7 @@ DistributionCustomizer.prototype = {
264264
Services.scriptSecurityManager.getSystemPrincipal()
265265
);
266266
} catch (e) {
267-
Cu.reportError(e);
267+
console.error(e);
268268
}
269269
}
270270

browser/components/doh/DoHConfig.jsm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function getProviderListFromPref(prefName) {
5656
try {
5757
return JSON.parse(prefVal);
5858
} catch (e) {
59-
Cu.reportError(`DoH provider list not a valid JSON array: ${prefName}`);
59+
console.error(`DoH provider list not a valid JSON array: ${prefName}`);
6060
}
6161
}
6262
return undefined;

browser/components/doh/DoHHeuristics.jsm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ async function platform() {
361361
indications = linkService.platformDNSIndications;
362362
} catch (e) {
363363
if (e.result != Cr.NS_ERROR_NOT_IMPLEMENTED) {
364-
Cu.reportError(e);
364+
console.error(e);
365365
}
366366
}
367367

browser/components/doh/TRRPerformance.jsm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class DNSLookup {
113113
{}
114114
);
115115
} catch (e) {
116-
Cu.reportError(e);
116+
console.error(e);
117117
}
118118
}
119119

@@ -155,7 +155,7 @@ class LookupAggregator {
155155

156156
run() {
157157
if (this._ran || this._aborted) {
158-
Cu.reportError("Trying to re-run a LookupAggregator.");
158+
console.error("Trying to re-run a LookupAggregator.");
159159
return;
160160
}
161161

@@ -211,7 +211,7 @@ class LookupAggregator {
211211
domain.includes(lazy.kCanonicalDomain)
212212
)
213213
) {
214-
Cu.reportError("Expected known domain for reporting, got " + domain);
214+
console.error("Expected known domain for reporting, got ", domain);
215215
return;
216216
}
217217

browser/components/downloads/DownloadsCommon.sys.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ export var DownloadsCommon = {
366366
}
367367
await download.manuallyRemoveData();
368368
if (clearHistory < 2) {
369-
lazy.DownloadHistory.updateMetaData(download).catch(Cu.reportError);
369+
lazy.DownloadHistory.updateMetaData(download).catch(console.error);
370370
}
371371
},
372372

@@ -861,7 +861,7 @@ DownloadsDataCtor.prototype = {
861861
this._isPrivate ? lazy.Downloads.PRIVATE : lazy.Downloads.PUBLIC
862862
)
863863
.then(list => list.removeFinished())
864-
.catch(Cu.reportError);
864+
.catch(console.error);
865865
},
866866

867867
// Integration with the asynchronous Downloads back-end
@@ -898,7 +898,7 @@ DownloadsDataCtor.prototype = {
898898

899899
// This state transition code should actually be located in a Downloads
900900
// API module (bug 941009).
901-
lazy.DownloadHistory.updateMetaData(download).catch(Cu.reportError);
901+
lazy.DownloadHistory.updateMetaData(download).catch(console.error);
902902
}
903903

904904
if (
@@ -932,7 +932,7 @@ DownloadsDataCtor.prototype = {
932932
* removeView before termination.
933933
*/
934934
addView(aView) {
935-
this._promiseList.then(list => list.addView(aView)).catch(Cu.reportError);
935+
this._promiseList.then(list => list.addView(aView)).catch(console.error);
936936
},
937937

938938
/**
@@ -942,9 +942,7 @@ DownloadsDataCtor.prototype = {
942942
* DownloadsView object to be removed.
943943
*/
944944
removeView(aView) {
945-
this._promiseList
946-
.then(list => list.removeView(aView))
947-
.catch(Cu.reportError);
945+
this._promiseList.then(list => list.removeView(aView)).catch(console.error);
948946
},
949947

950948
// Notifications sent to the most recent browser window only

browser/components/downloads/DownloadsMacFinderProgress.sys.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export var DownloadsMacFinderProgress = {
4646
let path = download.target.path;
4747

4848
finderProgress.init(path, () => {
49-
download.cancel().catch(Cu.reportError);
50-
download.removePartialData().catch(Cu.reportError);
49+
download.cancel().catch(console.error);
50+
download.removePartialData().catch(console.error);
5151
});
5252

5353
if (download.hasProgress) {

browser/components/downloads/DownloadsTaskbar.sys.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export var DownloadsTaskbar = {
119119
this._summary = summary;
120120
return this._summary.addView(this);
121121
})
122-
.catch(Cu.reportError);
122+
.catch(console.error);
123123
}
124124
},
125125

0 commit comments

Comments
 (0)