Bug 1294619 - Update jsdownloads code to enable the no-ex-assign rule for ESLint. r=jaws
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Fri, 12 Aug 2016 11:52:29 -0400
changeset 309375 8725f14625e0c87776f9acf66e6712ceca301000
parent 309374 6d1a4462e4898a7c270a98bdb01b3a7893a2fd06
child 309377 ef0801fdc7abe018a8b026c00e8bdebcc690001c
push id80592
push userkwierso@gmail.com
push dateMon, 15 Aug 2016 21:54:03 +0000
treeherdermozilla-inbound@16b35e0c7644 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1294619
milestone51.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 1294619 - Update jsdownloads code to enable the no-ex-assign rule for ESLint. r=jaws MozReview-Commit-ID: DiFGriLUdQq
toolkit/.eslintrc
toolkit/components/jsdownloads/src/DownloadCore.jsm
--- a/toolkit/.eslintrc
+++ b/toolkit/.eslintrc
@@ -75,17 +75,17 @@
 
     // No empty character classes in regex
     "no-empty-character-class": 2,
 
     // Disallow empty destructuring
     "no-empty-pattern": 2,
 
     // No assiging to exception variable
-    // "no-ex-assign": 2,
+    "no-ex-assign": 2,
 
     // No using !! where casting to boolean is already happening
     // "no-extra-boolean-cast": 2,
 
     // No double semicolon
     "no-extra-semi": 2,
 
     // No overwriting defined functions
--- a/toolkit/components/jsdownloads/src/DownloadCore.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadCore.jsm
@@ -504,17 +504,22 @@ this.Download.prototype = {
           // Cancellation exceptions will be changed in the catch block below.
           throw new DownloadError();
         }
 
         // Update the status properties for a successful download.
         this.progress = 100;
         this.succeeded = true;
         this.hasPartialData = false;
-      } catch (ex) {
+      } catch (originalEx) {
+        // We may choose a different exception to propagate in the code below,
+        // or wrap the original one. We do this mutation in a different variable
+        // because of the "no-ex-assign" ESLint rule.
+        let ex = originalEx;
+
         // Fail with a generic status code on cancellation, so that the caller
         // is forced to actually check the status properties to see if the
         // download was canceled or failed because of other reasons.
         if (this._promiseCanceled) {
           throw new DownloadError({ message: "Download canceled." });
         }
 
         // An HTTP 450 error code is used by Windows to indicate that a uri is