Browse Source

refactor: use optional catch binding (#39232)

Milan Burda 1 year ago
parent
commit
c9bae5da8e

+ 1 - 1
spec/api-app-spec.ts

@@ -345,7 +345,7 @@ describe('app module', () => {
           expectedAdditionalData: undefined
         });
         assert(false);
-      } catch (e) {
+      } catch {
         // This is expected.
       }
     });

+ 2 - 2
spec/api-auto-updater-spec.ts

@@ -32,7 +32,7 @@ ifdescribe(!process.mas)('autoUpdater module', function () {
         const url = 'http://electronjs.org';
         try {
           (autoUpdater.setFeedURL as any)(url, { header: 'val' });
-        } catch (err) { /* ignore */ }
+        } catch { /* ignore */ }
         expect(autoUpdater.getFeedURL()).to.equal(url);
       });
 
@@ -44,7 +44,7 @@ ifdescribe(!process.mas)('autoUpdater module', function () {
         const url = 'http://mymagicurl.local';
         try {
           autoUpdater.setFeedURL({ url });
-        } catch (err) { /* ignore */ }
+        } catch { /* ignore */ }
         expect(autoUpdater.getFeedURL()).to.equal(url);
       });
 

+ 2 - 2
spec/api-crash-reporter-spec.ts

@@ -116,7 +116,7 @@ function waitForNewFileInDir (dir: string): Promise<string[]> {
   function readdirIfPresent (dir: string): string[] {
     try {
       return fs.readdirSync(dir);
-    } catch (e) {
+    } catch {
       return [];
     }
   }
@@ -402,7 +402,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
       try {
         fs.rmdirSync(dir, { recursive: true });
         fs.mkdirSync(dir);
-      } catch (e) { /* ignore */ }
+      } catch { /* ignore */ }
 
       // 1. start the crash reporter.
       await remotely((port: number) => {

+ 1 - 1
spec/api-debugger-spec.ts

@@ -32,7 +32,7 @@ describe('debugger module', () => {
     it('fails when protocol version is not supported', done => {
       try {
         w.webContents.debugger.attach('2.0');
-      } catch (err) {
+      } catch {
         expect(w.webContents.debugger.isAttached()).to.be.false();
         done();
       }

+ 1 - 1
spec/api-net-log-spec.ts

@@ -55,7 +55,7 @@ describe('netLog module', () => {
       if (fs.existsSync(dumpFileDynamic)) {
         fs.unlinkSync(dumpFileDynamic);
       }
-    } catch (e) {
+    } catch {
       // Ignore error
     }
     expect(testNetLog().currentlyLogging).to.be.false('currently logging');

+ 2 - 2
spec/api-process-spec.ts

@@ -99,7 +99,7 @@ describe('process module', () => {
         defer(() => {
           try {
             fs.unlinkSync(filePath);
-          } catch (e) {
+          } catch {
             // ignore error
           }
         });
@@ -211,7 +211,7 @@ describe('process module', () => {
         defer(() => {
           try {
             fs.unlinkSync(filePath);
-          } catch (e) {
+          } catch {
             // ignore error
           }
         });

+ 3 - 3
spec/api-protocol-spec.ts

@@ -104,7 +104,7 @@ describe('protocol module', () => {
         try {
           callback(text);
           callback('');
-        } catch (error) {
+        } catch {
           // Ignore error
         }
       });
@@ -557,7 +557,7 @@ describe('protocol module', () => {
         try {
           callback(text);
           callback('');
-        } catch (error) {
+        } catch {
           // Ignore error
         }
       });
@@ -1106,7 +1106,7 @@ describe('protocol module', () => {
           // In case of failure, make sure we unhandle. But we should succeed
           // :)
           protocol.unhandle('test-scheme');
-        } catch (_ignored) { /* ignore */ }
+        } catch { /* ignore */ }
       });
       const resp1 = await net.fetch('test-scheme://foo');
       expect(resp1.status).to.equal(200);

+ 1 - 1
spec/api-web-contents-spec.ts

@@ -1786,7 +1786,7 @@ describe('webContents module', () => {
       const cleanup = () => {
         try {
           fs.unlinkSync(filePath);
-        } catch (e) {
+        } catch {
           // ignore error
         }
       };

+ 2 - 2
spec/fixtures/api/default-menu/main.js

@@ -22,11 +22,11 @@ try {
     setImmediate(() => {
       try {
         output(Menu.getApplicationMenu() === expectedMenu);
-      } catch (error) {
+      } catch {
         output(null);
       }
     });
   });
-} catch (error) {
+} catch {
   output(null);
 }

+ 1 - 1
spec/fixtures/module/echo-renamed.js

@@ -1,7 +1,7 @@
 let echo;
 try {
   echo = require('@electron-ci/echo');
-} catch (e) {
+} catch {
   process.exit(1);
 }
 process.exit(echo(0));

+ 1 - 1
spec/webview-spec.ts

@@ -2032,7 +2032,7 @@ describe('<webview> tag', function () {
             // Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha
             expect(imgBuffer[25]).to.equal(6);
             return;
-          } catch (e) {
+          } catch {
             /* drop the error */
           }
         }