Skip to content

Commit

Permalink
refactor: use optional catch binding (electron#39232)
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak authored Jul 27, 2023
1 parent 8dea783 commit c9bae5d
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion spec/api-app-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ describe('app module', () => {
expectedAdditionalData: undefined
});
assert(false);
} catch (e) {
} catch {
// This is expected.
}
});
Expand Down
4 changes: 2 additions & 2 deletions spec/api-auto-updater-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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);
});

Expand Down
4 changes: 2 additions & 2 deletions spec/api-crash-reporter-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function waitForNewFileInDir (dir: string): Promise<string[]> {
function readdirIfPresent (dir: string): string[] {
try {
return fs.readdirSync(dir);
} catch (e) {
} catch {
return [];
}
}
Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion spec/api-debugger-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion spec/api-net-log-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions spec/api-process-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('process module', () => {
defer(() => {
try {
fs.unlinkSync(filePath);
} catch (e) {
} catch {
// ignore error
}
});
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('process module', () => {
defer(() => {
try {
fs.unlinkSync(filePath);
} catch (e) {
} catch {
// ignore error
}
});
Expand Down
6 changes: 3 additions & 3 deletions spec/api-protocol-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('protocol module', () => {
try {
callback(text);
callback('');
} catch (error) {
} catch {
// Ignore error
}
});
Expand Down Expand Up @@ -557,7 +557,7 @@ describe('protocol module', () => {
try {
callback(text);
callback('');
} catch (error) {
} catch {
// Ignore error
}
});
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion spec/api-web-contents-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ describe('webContents module', () => {
const cleanup = () => {
try {
fs.unlinkSync(filePath);
} catch (e) {
} catch {
// ignore error
}
};
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/api/default-menu/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ try {
setImmediate(() => {
try {
output(Menu.getApplicationMenu() === expectedMenu);
} catch (error) {
} catch {
output(null);
}
});
});
} catch (error) {
} catch {
output(null);
}
2 changes: 1 addition & 1 deletion spec/fixtures/module/echo-renamed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let echo;
try {
echo = require('@electron-ci/echo');
} catch (e) {
} catch {
process.exit(1);
}
process.exit(echo(0));
2 changes: 1 addition & 1 deletion spec/webview-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
}
Expand Down

0 comments on commit c9bae5d

Please sign in to comment.