Bug 1539177 - netwerk/ manual ESLint no-throw-literal fixes. r=kershaw

Differential Revision: https://phabricator.services.mozilla.com/D25653

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ian Moody 2019-04-02 13:33:42 +00:00
Родитель 7907f0c225
Коммит e6abe56fc4
3 изменённых файлов: 9 добавлений и 13 удалений

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

@ -87,9 +87,6 @@ module.exports = {
}, {
// TODO: Bug 1246594. Empty this list once the rule has landed for all dirs
"files": [
"netwerk/protocol/http/WellKnownOpportunisticUtils.jsm",
"netwerk/test/httpserver/httpd.js",
"netwerk/test/httpserver/test/**",
"parser/htmlparser/tests/mochitest/parser_datreader.js",
"testing/marionette/event.js",
"testing/mochitest/**",

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

@ -98,25 +98,25 @@ function* LineIterator(data) {
* an Iterator which returns lines of text
* @param expectedLines : [string]
* an array of the expected lines of text
* @throws string
* an error message if iter doesn't agree with expectedLines
* @throws an error message if iter doesn't agree with expectedLines
*/
function expectLines(iter, expectedLines) {
var index = 0;
for (var line of iter) {
if (expectedLines.length == index)
throw "Error: got more than " + expectedLines.length + " expected lines!";
throw new Error(`Error: got more than ${expectedLines.length} expected lines!`);
var expected = expectedLines[index++];
if (expected !== line)
throw "Error on line " + index + "!\n" +
" actual: '" + line + "',\n" +
" expect: '" + expected + "'";
throw new Error(`Error on line ${index}!
actual: '${line}',
expect: '${expected}'`);
}
if (expectedLines.length !== index) {
throw "Expected more lines! Got " + index +
", expected " + expectedLines.length;
throw new Error(
`Expected more lines! Got ${index}, expected ${expectedLines.length}`
);
}
}

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

@ -40,8 +40,7 @@ function assertValidHeader(fieldName, fieldValue, headers) {
function assertInvalidHeader(fieldName, fieldValue, headers) {
try {
headers.setHeader(fieldName, fieldValue, false);
throw "Setting (" + fieldName + ", " +
fieldValue + ") as header succeeded!";
throw new Error(`Setting (${fieldName}, ${fieldValue}) as header succeeded!`);
} catch (e) {
if (e.result !== Cr.NS_ERROR_INVALID_ARG)
do_throw("Unexpected exception thrown: " + e);