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
});
assert(false);
} catch (e) {
} catch {
// This is expected.
}
});

View file

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

View file

@ -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) => {

View file

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

View file

@ -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');

View file

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

View file

@ -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);

View file

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

View file

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

View file

@ -1,7 +1,7 @@
let echo;
try {
echo = require('@electron-ci/echo');
} catch (e) {
} catch {
process.exit(1);
}
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
expect(imgBuffer[25]).to.equal(6);
return;
} catch (e) {
} catch {
/* drop the error */
}
}