js: Remove unused catch bindings

Optional catch bindings have been supported for quite a while now,
so we can treat unused error bindings in catch statements like any
other unused variable.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3684>
This commit is contained in:
Florian Müllner
2025-04-01 16:16:07 +02:00
committed by Bruce Leidl
parent a7410d82ac
commit 60aa4319d9
35 changed files with 56 additions and 56 deletions

View File

@ -1512,7 +1512,7 @@ class AppDisplay extends BaseAppView {
this._appInfoList = Shell.AppSystem.get_default().get_installed().filter(appInfo => {
try {
appInfo.get_id(); // catch invalid file encodings
} catch (e) {
} catch {
return false;
}
return !this._appFavorites.isFavorite(appInfo.get_id()) &&
@ -1737,7 +1737,7 @@ class AppDisplay extends BaseAppView {
schema_id: 'org.gnome.desktop.app-folders.folder',
path: newFolderPath,
});
} catch (e) {
} catch {
log('Error creating new folder');
return false;
}

View File

@ -190,7 +190,7 @@ export class AudioDeviceSelectionDBus {
let dialog;
try {
dialog = new AudioDeviceSelectionDialog(devices);
} catch (e) {
} catch {
invocation.return_value(null);
return;
}

View File

@ -503,7 +503,7 @@ const Background = GObject.registerClass({
Gio.FileQueryInfoFlags.NONE,
0,
this._cancellable);
} catch (e) {
} catch {
this._setLoaded();
return;
}

View File

@ -54,7 +54,7 @@ class AutomountManager {
const [inhibited] =
await this._session.IsInhibitedAsync(GNOME_SESSION_AUTOMOUNT_INHIBIT);
this._inhibited = inhibited;
} catch (e) {}
} catch {}
}
_startupMountAll() {

View File

@ -494,7 +494,7 @@ class VPNRequestHandler extends Signals.EventEmitter {
} else {
try {
this._stdin.write('QUIT\n\n', null);
} catch (e) { /* ignore broken pipe errors */ }
} catch { /* ignore broken pipe errors */ }
}
this.destroy();
@ -544,7 +544,7 @@ class VPNRequestHandler extends Signals.EventEmitter {
if (line === '' && this._previousLine === '') {
try {
this._stdin.write('QUIT\n\n', null);
} catch (e) { /* ignore broken pipe errors */ }
} catch { /* ignore broken pipe errors */ }
} else {
this._agent.add_vpn_secret(this._requestId, this._previousLine, line);
this._previousLine = undefined;

View File

@ -425,7 +425,7 @@ class AuthenticationAgent extends Shell.PolkitAuthenticationAgent {
enable() {
try {
this.register();
} catch (e) {
} catch {
log('Failed to register AuthenticationAgent');
}
}
@ -433,7 +433,7 @@ class AuthenticationAgent extends Shell.PolkitAuthenticationAgent {
disable() {
try {
this.unregister();
} catch (e) {
} catch {
log('Failed to unregister AuthenticationAgent');
}
}

View File

@ -174,7 +174,7 @@ function findAppFromInhibitor(inhibitor) {
let desktopFile;
try {
[desktopFile] = inhibitor.GetAppIdSync();
} catch (e) {
} catch {
// XXX -- sometimes JIT inhibitors generated by gnome-session
// get removed too soon. Don't fail in this case.
log(`gnome-session gave us a dead inhibitor: ${inhibitor.get_object_path()}`);

View File

@ -348,7 +348,7 @@ Object.prototype.toString = function () {
return base.replace(/\]$/, ` delegate for ${this.actor.toString().substring(1)}`);
else
return base;
} catch (e) {
} catch {
return base;
}
};

View File

@ -88,7 +88,7 @@ export function uninstallExtension(uuid) {
const updatesDir = Gio.File.new_for_path(GLib.build_filenamev(
[global.userdatadir, 'extension-updates', extension.uuid]));
FileUtils.recursivelyDeleteDir(updatesDir, true);
} catch (e) {
} catch {
// not an error
}

View File

@ -667,7 +667,7 @@ export class ExtensionManager extends Signals.EventEmitter {
try {
FileUtils.recursivelyDeleteDir(extensionDir, false);
FileUtils.recursivelyMoveDir(dir, extensionDir);
} catch (e) {
} catch {
log(`Failed to install extension updates for ${uuid}`);
} finally {
FileUtils.recursivelyDeleteDir(dir, true);

View File

@ -228,7 +228,7 @@ class IbusCandidatePopup extends BoxPointer.BoxPointer {
rect.width,
rect.height);
});
} catch (e) {
} catch {
// Only recent IBus versions have support for this signal
// which is used for wayland clients. In order to work
// with older IBus versions we can silently ignore the

View File

@ -1439,7 +1439,7 @@ export const Keyboard = GObject.registerClass({
try {
keyboardModel = new KeyboardModel(group);
break;
} catch (e) {
} catch {
// Ignore this error and fall back to next model
}
}

View File

@ -467,7 +467,7 @@ class ObjInspector extends St.ScrollView {
try {
let prop = obj[propName];
link = new ObjLink(this._lookingGlass, prop);
} catch (e) {
} catch {
link = new St.Label({text: '<error>'});
}
let box = new St.BoxLayout();
@ -1589,7 +1589,7 @@ class LookingGlass extends St.BoxLayout {
getResult(idx) {
try {
return this._resultsArea.get_child_at_index(idx - this._offset).o;
} catch (e) {
} catch {
throw new Error(`Unknown result at index ${idx}`);
}
}

View File

@ -156,7 +156,7 @@ export async function start() {
// toString() can throw
if (msg)
args.unshift(`${msg}:`);
} catch (e) {}
} catch {}
console.error(...args);
};

View File

@ -77,7 +77,7 @@ export function loadRemoteSearchProviders(searchSettings) {
try {
keyfile.load_from_file(path, 0);
} catch (e) {
} catch {
return;
}
@ -99,7 +99,7 @@ export function loadRemoteSearchProviders(searchSettings) {
appInfo = Gio.DesktopAppInfo.new(desktopId);
if (!appInfo.should_show())
return;
} catch (e) {
} catch {
log(`Ignoring search provider ${path}: missing DesktopId`);
return;
}
@ -107,14 +107,14 @@ export function loadRemoteSearchProviders(searchSettings) {
let autoStart = true;
try {
autoStart = keyfile.get_boolean(group, 'AutoStart');
} catch (e) {
} catch {
// ignore error
}
let version = '1';
try {
version = keyfile.get_string(group, 'Version');
} catch (e) {
} catch {
// ignore error
}
@ -126,7 +126,7 @@ export function loadRemoteSearchProviders(searchSettings) {
remoteProvider.defaultEnabled = true;
try {
remoteProvider.defaultEnabled = !keyfile.get_boolean(group, 'DefaultDisabled');
} catch (e) {
} catch {
// ignore error
}

View File

@ -2621,7 +2621,7 @@ export class ScreenshotService {
screenshot.screenshot_area(x, y, width, height, stream),
]);
this._onScreenshotComplete(stream, file, invocation);
} catch (e) {
} catch {
invocation.return_value(new GLib.Variant('(bs)', [false, '']));
} finally {
this._removeShooterForSender(invocation.get_sender());
@ -2644,7 +2644,7 @@ export class ScreenshotService {
screenshot.screenshot_window(includeFrame, includeCursor, stream),
]);
this._onScreenshotComplete(stream, file, invocation);
} catch (e) {
} catch {
invocation.return_value(new GLib.Variant('(bs)', [false, '']));
} finally {
this._removeShooterForSender(invocation.get_sender());
@ -2667,7 +2667,7 @@ export class ScreenshotService {
screenshot.screenshot(includeCursor, stream),
]);
this._onScreenshotComplete(stream, file, invocation);
} catch (e) {
} catch {
invocation.return_value(new GLib.Variant('(bs)', [false, '']));
} finally {
this._removeShooterForSender(invocation.get_sender());
@ -2696,7 +2696,7 @@ export class ScreenshotService {
try {
Main.screenshotUI.open(UIMode.SCREENSHOT_ONLY);
} catch (e) {
} catch {
Main.screenshotUI.disconnectObject(invocation);
invocation.return_value(new GLib.Variant('(bs)', [false, '']));
}
@ -2717,7 +2717,7 @@ export class ScreenshotService {
areaRectangle.x, areaRectangle.y,
areaRectangle.width, areaRectangle.height);
invocation.return_value(GLib.Variant.new('(iiii)', retRectangle));
} catch (e) {
} catch {
invocation.return_error_literal(
Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
'Operation was cancelled');
@ -2763,7 +2763,7 @@ export class ScreenshotService {
]),
}]);
invocation.return_value(retval);
} catch (e) {
} catch {
invocation.return_error_literal(
Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
'Operation was cancelled');

View File

@ -274,7 +274,7 @@ const SearchResultsBase = GObject.registerClass({
this._setMoreCount(this.provider.canLaunchSearch ? moreCount : 0);
this.show();
callback();
} catch (e) {
} catch {
this._clearResultDisplay();
callback();
}

View File

@ -112,7 +112,7 @@ function _loadMode(file, info) {
[success_, fileContent] = file.load_contents(null);
const decoder = new TextDecoder();
newMode = JSON.parse(decoder.decode(fileContent));
} catch (e) {
} catch {
return;
}

View File

@ -123,7 +123,7 @@ const BackgroundAppMenuItem = GObject.registerClass({
try {
await this.app.activate_action('quit', null, 0, -1, null);
} catch (_error) {
} catch {
try {
const appId = this.app.get_id().replace(/\.desktop$/, '');
Util.trySpawn(['flatpak', 'kill', appId]);

View File

@ -226,7 +226,7 @@ class InputSourceSystemSettings extends InputSourceSettings {
new GLib.Variant('(s)', [this._BUS_IFACE]),
null, Gio.DBusCallFlags.NONE, -1, null);
[props] = result.deepUnpack();
} catch (e) {
} catch {
log(`Could not get properties from ${this._BUS_NAME}`);
return;
}

View File

@ -2126,7 +2126,7 @@ class Indicator extends SystemIndicator {
const state = await this._client.check_connectivity_async(null);
if (state >= NM.ConnectivityState.FULL)
this._portalHandler.removeConnection(path);
} catch (e) { }
} catch {}
});
this._client.connectObject(

View File

@ -499,7 +499,7 @@ export const UnlockDialog = GObject.registerClass({
this._gdmClient.set_enabled_extensions([
Gdm.UserVerifierChoiceList.interface_info().name,
]);
} catch (e) {
} catch {
}
this._adjustment = new St.Adjustment({