From ced8871783418570000c0c4cb37b0b8a0d25a239 Mon Sep 17 00:00:00 2001 From: Ian Moody Date: Tue, 16 Apr 2019 15:02:05 +0000 Subject: [PATCH] Bug 1544285 - tools/ automated ESLint no-throw-literal fixes. r=dbaron Result of running: $ mach eslint -funix tools/ | sed -Ee 's/:.+//' - | xargs sed -E \ -e 's/throw ((["`])[^"]+\2);/throw new Error(\1);/g' \ -e 's/throw ((["`])[^"]+\2 \+ [^ ";]+);/throw new Error(\1);/g' \ -e 's/throw \(/throw new Error(/g' -i Differential Revision: https://phabricator.services.mozilla.com/D27450 --HG-- extra : moz-landing-system : lando --- .eslintrc.js | 1 - tools/leak-gauge/leak-gauge.html | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cd6f8ce94ce1..a5da4d702d34 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -87,7 +87,6 @@ module.exports = { }, { // TODO: Bug 1246594. Empty this list once the rule has landed for all dirs "files": [ - "tools/leak-gauge/leak-gauge.html", "xpcom/tests/unit/test_iniParser.js", ], "rules": { diff --git a/tools/leak-gauge/leak-gauge.html b/tools/leak-gauge/leak-gauge.html index 9273ae6b95a3..e14010ca48a9 100644 --- a/tools/leak-gauge/leak-gauge.html +++ b/tools/leak-gauge/leak-gauge.html @@ -44,7 +44,7 @@ function runContents(result, contents) { if (verb == "created") { let m = rest.match(/ outer=([0-9a-f]*)$/); if (!m) - throw "outer expected"; + throw new Error("outer expected"); this.windows[addr] = { outer: m[1] }; ++this.count; } else if (verb == "destroyed") { @@ -52,7 +52,7 @@ function runContents(result, contents) { } else if (verb == "SetNewDocument") { let m = rest.match(/^ (.*)$/); if (!m) - throw "URI expected"; + throw new Error("URI expected"); this.windows[addr][m[1]] = true; } } @@ -94,7 +94,7 @@ function runContents(result, contents) { verb == "StartDocumentLoad") { var m = rest.match(/^ (.*)$/); if (!m) - throw "URI expected"; + throw new Error("URI expected"); var uri = m[1]; var doc_info = this.docs[addr]; doc_info[uri] = true; @@ -138,7 +138,7 @@ function runContents(result, contents) { verb == "SetCurrentURI") { var m = rest.match(/^ (.*)$/); if (!m) - throw "URI expected"; + throw new Error("URI expected"); this.shells[addr][m[1]] = true; } } @@ -174,7 +174,7 @@ function runContents(result, contents) { } else if (verb == "Init") { var m = rest.match(/^ document=(.*)$/); if (!m) - throw "document pointer expected"; + throw new Error("document pointer expected"); var nim_info = this.nims[addr]; var doc = m[1]; if (doc != "0") {