refactor: use optional catch binding (#39232)

This commit is contained in:
Milan Burda 2023-07-27 16:53:45 +02:00 committed by GitHub
parent 8dea783805
commit c9bae5da8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 17 additions and 17 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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