Skip to content

Commit

Permalink
Remove (e) from catches when not used
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Jan 29, 2025
1 parent 1737ada commit 8736870
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 50 deletions.
7 changes: 3 additions & 4 deletions installed-tests/fixtures/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Core = await import(`file://${Config.PACKAGE_DATADIR}/service/core.js`);
let GioUnix;
try {
GioUnix = (await import('gi://GioUnix')).default;
} catch (e) {
} catch {
GioUnix = {
InputStream: Gio.UnixInputStream,
OutputStream: Gio.UnixOutputStream,
Expand Down Expand Up @@ -89,7 +89,7 @@ export const ChannelService = GObject.registerClass({
try {
this._tcp.add_inet_port(this.port, null);
break;
} catch (e) {
} catch {
this._port++;
}
}
Expand Down Expand Up @@ -146,7 +146,7 @@ export const ChannelService = GObject.registerClass({
this._udp6_source = this._udp6.create_source(GLib.IOCondition.IN, null);
this._udp6_source.set_callback(this._onIncomingIdentity.bind(this, this._udp6));
this._udp6_source.attach(null);
} catch (e) {
} catch {
this._udp6 = null;
}

Expand Down Expand Up @@ -547,4 +547,3 @@ export const Channel = GObject.registerClass({
}
}
});

5 changes: 2 additions & 3 deletions installed-tests/fixtures/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ function removeDirectory(file) {
removeDirectory(iter.get_child(info));

iter.close(null);
} catch (e) {
} catch {
}

file.delete(null);
} catch (e) {
} catch {
}
}

Expand Down Expand Up @@ -394,4 +394,3 @@ export class TestRig {
removeDirectory(this._tmpdir);
}
}

8 changes: 4 additions & 4 deletions src/preferences/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export const Panel = GObject.registerClass({
const isPresent = value.get_boolean();

resolve(isPresent);
} catch (e) {
} catch {
resolve(false);
}
}
Expand All @@ -614,7 +614,7 @@ export const Panel = GObject.registerClass({

this.battery_system_label.visible = hasBattery;
this.battery_system.visible = hasBattery;
} catch (e) {
} catch {
this.battery_system_label.visible = false;
this.battery_system.visible = false;
}
Expand Down Expand Up @@ -814,7 +814,7 @@ export const Panel = GObject.registerClass({

try {
applications = JSON.parse(settings.get_string('applications'));
} catch (e) {
} catch {
applications = {};
}

Expand Down Expand Up @@ -858,7 +858,7 @@ export const Panel = GObject.registerClass({

try {
applications = JSON.parse(settings.get_string('applications'));
} catch (e) {
} catch {
applications = {};
}

Expand Down
7 changes: 3 additions & 4 deletions src/service/backends/lan.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as Core from '../core.js';
let GioUnix;
try {
GioUnix = (await import('gi://GioUnix')).default;
} catch (e) {
} catch {
GioUnix = {
InputStream: Gio.UnixInputStream,
OutputStream: Gio.UnixOutputStream,
Expand Down Expand Up @@ -42,7 +42,7 @@ try {
Gio.SocketType.STREAM,
Gio.SocketProtocol.TCP
).get_option(6, 5);
} catch (e) {
} catch {
_LINUX_SOCKETS = false;
}

Expand Down Expand Up @@ -282,7 +282,7 @@ export const ChannelService = GObject.registerClass({
this._udp6_source = this._udp6.create_source(GLib.IOCondition.IN, null);
this._udp6_source.set_callback(this._onIncomingIdentity.bind(this, this._udp6));
this._udp6_source.attach(null);
} catch (e) {
} catch {
this._udp6 = null;
}

Expand Down Expand Up @@ -886,4 +886,3 @@ export const Channel = GObject.registerClass({
}
}
});

5 changes: 2 additions & 3 deletions src/service/components/atspi.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class Controller {

modifier = keymap.get_entries_for_keyval(Gdk.KEY_Super_L)[1][0];
XKeycode.Super_L = modifier.keycode;
} catch (e) {
} catch {
debug('using default modifier keycodes');
}
}
Expand Down Expand Up @@ -304,9 +304,8 @@ export default class Controller {
destroy() {
try {
Atspi.exit();
} catch (e) {
} catch {
// Silence errors
}
}
}

3 changes: 1 addition & 2 deletions src/service/components/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ try {
EBook = (await import('gi://EBook')).default;
EBookContacts = (await import('gi://EBookContacts')).default;
EDataServer = (await import('gi://EDataServer')).default;
} catch (e) {
} catch {
HAVE_EDS = false;
}

Expand Down Expand Up @@ -610,4 +610,3 @@ const Store = GObject.registerClass({
});

export default Store;

2 changes: 1 addition & 1 deletion src/service/components/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const RemoteSession = GObject.registerClass({
get session_id() {
try {
return this.get_cached_property('SessionId').unpack();
} catch (e) {
} catch {
return null;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/service/components/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ const PlayerProxy = GObject.registerClass({
_get(proxy, name, fallback = null) {
try {
return proxy.get_cached_property(name).recursiveUnpack();
} catch (e) {
} catch {
return fallback;
}
}
Expand Down Expand Up @@ -707,7 +707,7 @@ const PlayerProxy = GObject.registerClass({
);

return reply.recursiveUnpack()[0];
} catch (e) {
} catch {
return 0;
}
}
Expand Down Expand Up @@ -1000,4 +1000,3 @@ const Manager = GObject.registerClass({
* The service class for this component
*/
export default Manager;

2 changes: 1 addition & 1 deletion src/service/components/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const Listener = GObject.registerClass({
const appInfo = Gio.DesktopAppInfo.new(`${appId}.desktop`);
this._names[appName] = appInfo.get_name();
appName = appInfo.get_name();
} catch (e) {
} catch {
// Silence errors
}

Expand Down
4 changes: 2 additions & 2 deletions src/service/components/pulseaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ try {
GIRepository.Repository.prepend_library_path(typelibDir);

Gvc = (await import('gi://Gvc')).default;
} catch (e) {}
} catch {}


/**
Expand All @@ -33,7 +33,7 @@ if (Gvc) {
return this.description;

return `${this.get_port().human_port} (${this.description})`;
} catch (e) {
} catch {
return this.description;
}
},
Expand Down
3 changes: 1 addition & 2 deletions src/service/components/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import GLib from 'gi://GLib';
let GSound = null;
try {
GSound = (await import('gi://GSound')).default;
} catch (e) {}
} catch {}


const Player = class Player {
Expand Down Expand Up @@ -169,4 +169,3 @@ const Player = class Player {
* The service class for this component
*/
export default Player;

2 changes: 1 addition & 1 deletion src/service/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function _getDeviceType() {
return 'laptop';

return 'desktop';
} catch (e) {
} catch {
return 'desktop';
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ const Device = GObject.registerClass({

if (val.unpack() === actionName)
return i;
} catch (e) {
} catch {
continue;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/service/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ Gio.File.rm_rf = function (file) {
Gio.File.rm_rf(iter.get_child(info));

iter.close(null);
} catch (e) {
} catch {
// Silence errors
}

file.delete(null);
} catch (e) {
} catch {
// Silence errors
}
};
Expand Down Expand Up @@ -310,7 +310,7 @@ function _full_unpack(obj) {
unpacked[key] = Gio.Icon.deserialize(value);
else
unpacked[key] = _full_unpack(value);
} catch (e) {
} catch {
unpacked[key] = _full_unpack(value);
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/service/nativeMessagingHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import system from 'system';
let GioUnix;
try {
GioUnix = (await import('gi://GioUnix?version=2.0')).default;
} catch (e) {
} catch {
GioUnix = {
InputStream: Gio.UnixInputStream,
OutputStream: Gio.UnixOutputStream,
Expand Down Expand Up @@ -142,7 +142,7 @@ const NativeMessagingHost = GObject.registerClass({
}

return GLib.SOURCE_CONTINUE;
} catch (e) {
} catch {
this.quit();
}
}
Expand All @@ -152,7 +152,7 @@ const NativeMessagingHost = GObject.registerClass({
const data = JSON.stringify(message);
this._stdout.put_int32(data.length, null);
this._stdout.put_string(data, null);
} catch (e) {
} catch {
this.quit();
}
}
Expand Down Expand Up @@ -186,7 +186,7 @@ const NativeMessagingHost = GObject.registerClass({
_proxyGetter(name) {
try {
return this.get_cached_property(name).unpack();
} catch (e) {
} catch {
return null;
}
}
Expand Down Expand Up @@ -222,4 +222,3 @@ const NativeMessagingHost = GObject.registerClass({

// NOTE: must not pass ARGV
await (new NativeMessagingHost()).runAsync([system.programInvocationName]);

4 changes: 2 additions & 2 deletions src/service/plugins/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const setEBookContacts = (ebook) => { // This function is only for tests

try {
EBookContacts = (await import('gi://EBookContacts')).default;
} catch (e) {
} catch {
EBookContacts = null;
}

Expand Down Expand Up @@ -215,7 +215,7 @@ const ContactsPlugin = GObject.registerClass({
return output.join('');

// Fallback to old unfaithful
} catch (e) {
} catch {
try {
return decodeURIComponent(escape(input));

Expand Down
2 changes: 1 addition & 1 deletion src/service/plugins/runcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const RunCommandPlugin = GObject.registerClass({
if (typeof commandList === 'string') {
try {
commandList = JSON.parse(commandList);
} catch (e) {
} catch {
commandList = {};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/plugins/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ const FileChooserDialog = GObject.registerClass({
chooser.preview_widget.pixbuf = pixbuf;
chooser.preview_widget.visible = true;
chooser.preview_widget_active = true;
} catch (e) {
} catch {
chooser.preview_widget.visible = false;
chooser.preview_widget_active = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shell/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const Clipboard = GObject.registerClass({
invocation.return_value(retval);

// Without a response, the client will wait for timeout
} catch (e) {
} catch {
invocation.return_dbus_error(
'org.gnome.gjs.JSError.ValueError',
'Service implementation returned an incorrect value type'
Expand Down
6 changes: 3 additions & 3 deletions src/shell/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const NotificationBanner = GObject.registerClass({
(connection, res) => {
try {
connection.call_finish(res);
} catch (e) {
} catch {
// Silence errors
}
}
Expand Down Expand Up @@ -198,7 +198,7 @@ const Source = GObject.registerClass({
(connection, res) => {
try {
connection.call_finish(res);
} catch (e) {
} catch {
// If we fail, reset in case we can try again
notification._remoteClosed = false;
}
Expand Down Expand Up @@ -433,7 +433,7 @@ export function patchGtkNotificationSources() {
(connection, res) => {
try {
connection.call_finish(res);
} catch (e) {
} catch {
// If we fail, reset in case we can try again
notification._remoteWithdrawn = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shell/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Config from '../config.js';
let St = null; // St is not available for prefs.js importing this file.
try {
St = (await import('gi://St')).default;
} catch (e) { }
} catch { }


/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const Device = GObject.registerClass({
_get(name, fallback = null) {
try {
return this.get_cached_property(name).unpack();
} catch (e) {
} catch {
return fallback;
}
}
Expand Down
Loading

0 comments on commit 8736870

Please sign in to comment.