Bug 1536556 - Replace new Error(Cr.ERROR) with new Component.Exception. r=mossop

Passing Cr.ERROR to an Error constructor is incorrect since it just sets the
message of the error to the integer value of the Cr.ERROR. Cr.ERRORs need to be
used as the second argument to Component.Exception to correctly construct an
Exception object with its result property set to the Cr.ERROR value.

This was done automatically by an expansion of the new
mozilla/no-throw-cr-literal eslint rule that will be introduced in the next
commit.

Differential Revision: https://phabricator.services.mozilla.com/D28075
This commit is contained in:
Ian Moody 2020-05-05 15:00:55 +00:00
Родитель 85f9392bc8
Коммит 9243ee5033
4 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -52,7 +52,7 @@ const gInterfaceRequestor = {
return this;
}
throw new Error(Cr.NS_ERROR_NO_INTERFACE);
throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},
};

Просмотреть файл

@ -72,7 +72,7 @@ var gMockPrompter = {
return this;
}
throw new Error(Cr.NS_ERROR_NO_INTERFACE);
throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},
};

Просмотреть файл

@ -25,7 +25,7 @@ function run_test() {
let xulRuntimeFactory = {
createInstance(outer, iid) {
if (outer != null) {
throw new Error(Cr.NS_ERROR_NO_AGGREGATION);
throw Components.Exception("", Cr.NS_ERROR_NO_AGGREGATION);
}
return xulRuntime.QueryInterface(iid);
},

Просмотреть файл

@ -175,7 +175,7 @@ function RedirectAndAuthStopper() {}
RedirectAndAuthStopper.prototype = {
// nsIChannelEventSink
asyncOnChannelRedirect(oldChannel, newChannel, flags, callback) {
throw new Error(Cr.NS_ERROR_ENTITY_CHANGED);
throw Components.Exception("", Cr.NS_ERROR_ENTITY_CHANGED);
},
// nsIAuthPrompt2
@ -184,7 +184,7 @@ RedirectAndAuthStopper.prototype = {
},
asyncPromptAuth(channel, callback, context, level, authInfo) {
throw new Error(Cr.NS_ERROR_NOT_IMPLEMENTED);
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
},
getInterface(iid) {