style: Use space after catch

We are currently inconsistent with whether or not to put a space
after catch clauses. While the predominant style is to omit it,
that's inconsistent with the style we use for any other statement.
There's not really a good reason to stick with it, so switch to
the style gjs/eslint default to.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
This commit is contained in:
Florian Müllner 2019-01-29 02:26:39 +01:00
parent d008c6c5c5
commit f250643385
26 changed files with 53 additions and 53 deletions

View File

@ -23,7 +23,7 @@ function FprintManager() {
try { try {
self.init(null); self.init(null);
} catch(e) { } catch (e) {
log('Failed to connect to Fprint service: ' + e.message); log('Failed to connect to Fprint service: ' + e.message);
return null; return null;
} }

View File

@ -342,7 +342,7 @@ var ShellUserVerifier = class {
try { try {
this._clearUserVerifier(); this._clearUserVerifier();
this._userVerifier = client.open_reauthentication_channel_finish(result); this._userVerifier = client.open_reauthentication_channel_finish(result);
} catch(e) { } catch (e) {
if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
return; return;
if (e.matches(Gio.DBusError, Gio.DBusError.ACCESS_DENIED) && if (e.matches(Gio.DBusError, Gio.DBusError.ACCESS_DENIED) &&
@ -369,7 +369,7 @@ var ShellUserVerifier = class {
try { try {
this._clearUserVerifier(); this._clearUserVerifier();
this._userVerifier = client.get_user_verifier_finish(result); this._userVerifier = client.get_user_verifier_finish(result);
} catch(e) { } catch (e) {
if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
return; return;
this._reportInitError('Failed to obtain user verifier', e); this._reportInitError('Failed to obtain user verifier', e);
@ -429,7 +429,7 @@ var ShellUserVerifier = class {
(obj, result) => { (obj, result) => {
try { try {
obj.call_begin_verification_for_user_finish(result); obj.call_begin_verification_for_user_finish(result);
} catch(e) { } catch (e) {
if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
return; return;
this._reportInitError('Failed to start verification for user', e); this._reportInitError('Failed to start verification for user', e);
@ -444,7 +444,7 @@ var ShellUserVerifier = class {
(obj, result) => { (obj, result) => {
try { try {
obj.call_begin_verification_finish(result); obj.call_begin_verification_finish(result);
} catch(e) { } catch (e) {
if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
return; return;
this._reportInitError('Failed to start verification', e); this._reportInitError('Failed to start verification', e);

View File

@ -235,7 +235,7 @@ var ExtensionFinder = class {
: ExtensionType.SYSTEM; : ExtensionType.SYSTEM;
try { try {
extension = createExtensionObject(uuid, extensionDir, type); extension = createExtensionObject(uuid, extensionDir, type);
} catch(e) { } catch (e) {
logError(e, 'Could not load extension %s'.format(uuid)); logError(e, 'Could not load extension %s'.format(uuid));
return; return;
} }

View File

@ -62,7 +62,7 @@ var IBusManager = class {
try { try {
Gio.Subprocess.new(['ibus-daemon', '--xim', '--panel', 'disable'], Gio.Subprocess.new(['ibus-daemon', '--xim', '--panel', 'disable'],
Gio.SubprocessFlags.NONE); Gio.SubprocessFlags.NONE);
} catch(e) { } catch (e) {
log('Failed to launch ibus-daemon: ' + e.message); log('Failed to launch ibus-daemon: ' + e.message);
} }
} }
@ -138,7 +138,7 @@ var IBusManager = class {
engine = this._ibus.get_global_engine_async_finish(result); engine = this._ibus.get_global_engine_async_finish(result);
if (!engine) if (!engine)
return; return;
} catch(e) { } catch (e) {
return; return;
} }
this._engineChanged(this._ibus, engine.get_name()); this._engineChanged(this._ibus, engine.get_name());

View File

@ -43,7 +43,7 @@ function canLock() {
let version = result.deep_unpack()[0].deep_unpack(); let version = result.deep_unpack()[0].deep_unpack();
return haveSystemd() && versionCompare('3.5.91', version); return haveSystemd() && versionCompare('3.5.91', version);
} catch(e) { } catch (e) {
return false; return false;
} }
} }
@ -185,7 +185,7 @@ var LoginManagerSystemd = class {
let [outVariant, fdList] = proxy.call_with_unix_fd_list_finish(result); let [outVariant, fdList] = proxy.call_with_unix_fd_list_finish(result);
fd = fdList.steal_fds()[0]; fd = fdList.steal_fds()[0];
callback(new Gio.UnixInputStream({ fd: fd })); callback(new Gio.UnixInputStream({ fd: fd }));
} catch(e) { } catch (e) {
logError(e, "Error getting systemd inhibitor"); logError(e, "Error getting systemd inhibitor");
callback(null); callback(null);
} }

View File

@ -94,7 +94,7 @@ var ObjectManager = class {
(initable, result) => { (initable, result) => {
try { try {
initable.init_finish(result); initable.init_finish(result);
} catch(e) { } catch (e) {
logError(e, 'could not initialize proxy for interface ' + interfaceName); logError(e, 'could not initialize proxy for interface ' + interfaceName);
if (onFinished) if (onFinished)
@ -156,7 +156,7 @@ var ObjectManager = class {
_onManagerProxyLoaded(initable, result) { _onManagerProxyLoaded(initable, result) {
try { try {
initable.init_finish(result); initable.init_finish(result);
} catch(e) { } catch (e) {
logError(e, 'could not initialize object manager for object ' + this._serviceName); logError(e, 'could not initialize object manager for object ' + this._serviceName);
this._tryToCompleteLoad(); this._tryToCompleteLoad();

View File

@ -93,7 +93,7 @@ function spawnApp(argv) {
let context = global.create_app_launch_context(0, -1); let context = global.create_app_launch_context(0, -1);
app.launch([], context); app.launch([], context);
} catch(err) { } catch (err) {
_handleSpawnError(argv[0], err); _handleSpawnError(argv[0], err);
} }
} }

View File

@ -178,7 +178,7 @@ var WeatherClient = class {
(o, res) => { (o, res) => {
try { try {
this._gclueService = Geoclue.Simple.new_finish(res); this._gclueService = Geoclue.Simple.new_finish(res);
} catch(e) { } catch (e) {
log('Failed to connect to Geoclue2 service: ' + e.message); log('Failed to connect to Geoclue2 service: ' + e.message);
this._setLocation(this._mostRecentLocation); this._setLocation(this._mostRecentLocation);
return; return;

View File

@ -69,7 +69,7 @@ function _getFolderName(folder) {
try { try {
keyfile.load_from_data_dirs(path, GLib.KeyFileFlags.NONE); keyfile.load_from_data_dirs(path, GLib.KeyFileFlags.NONE);
name = keyfile.get_locale_string('Desktop Entry', 'Name', null); name = keyfile.get_locale_string('Desktop Entry', 'Name', null);
} catch(e) { } catch (e) {
return name; return name;
} }
} }
@ -359,7 +359,7 @@ var AllView = class AllView extends BaseAppView {
this._appInfoList = Shell.AppSystem.get_default().get_installed().filter(appInfo => { this._appInfoList = Shell.AppSystem.get_default().get_installed().filter(appInfo => {
try { try {
(appInfo.get_id()); // catch invalid file encodings (appInfo.get_id()); // catch invalid file encodings
} catch(e) { } catch (e) {
return false; return false;
} }
return appInfo.should_show(); return appInfo.should_show();

View File

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

View File

@ -168,7 +168,7 @@ var DBusEventSource = class DBusEventSource {
try { try {
this._dbusProxy.init_finish(result); this._dbusProxy.init_finish(result);
loaded = true; loaded = true;
} catch(e) { } catch (e) {
if (e.matches(Gio.DBusError, Gio.DBusError.TIMED_OUT)) { if (e.matches(Gio.DBusError, Gio.DBusError.TIMED_OUT)) {
// Ignore timeouts and install signals as normal, because with high // Ignore timeouts and install signals as normal, because with high
// probability the service will appear later on, and we will get a // probability the service will appear later on, and we will get a

View File

@ -406,7 +406,7 @@ var VPNRequestHandler = class {
this._vpnChildFinished.bind(this)); this._vpnChildFinished.bind(this));
this._writeConnection(); this._writeConnection();
} catch(e) { } catch (e) {
logError(e, 'error while spawning VPN auth helper'); logError(e, 'error while spawning VPN auth helper');
this._agent.respond(requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR); this._agent.respond(requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR);
@ -423,7 +423,7 @@ var VPNRequestHandler = class {
} else { } else {
try { try {
this._stdin.write('QUIT\n\n', null); this._stdin.write('QUIT\n\n', null);
} catch(e) { /* ignore broken pipe errors */ } } catch (e) { /* ignore broken pipe errors */ }
} }
this.destroy(); this.destroy();
@ -472,7 +472,7 @@ var VPNRequestHandler = class {
if (line == '' && this._previousLine == '') { if (line == '' && this._previousLine == '') {
try { try {
this._stdin.write('QUIT\n\n', null); this._stdin.write('QUIT\n\n', null);
} catch(e) { /* ignore broken pipe errors */ } } catch (e) { /* ignore broken pipe errors */ }
} else { } else {
this._agent.set_password(this._requestId, this._previousLine, line); this._agent.set_password(this._requestId, this._previousLine, line);
this._previousLine = undefined; this._previousLine = undefined;
@ -560,7 +560,7 @@ var VPNRequestHandler = class {
this._agent.set_password(this._requestId, groups[i], value); this._agent.set_password(this._requestId, groups[i], value);
} }
} }
} catch(e) { } catch (e) {
// No output is a valid case it means "both secrets are stored" // No output is a valid case it means "both secrets are stored"
if (data.length > 0) { if (data.length > 0) {
logError(e, 'error while reading VPN plugin output keyfile'); logError(e, 'error while reading VPN plugin output keyfile');
@ -594,7 +594,7 @@ var VPNRequestHandler = class {
this._stdin.write('SECRET_VAL=' + (value || '') + '\n\n', null); this._stdin.write('SECRET_VAL=' + (value || '') + '\n\n', null);
}); });
this._stdin.write('DONE\n\n', null); this._stdin.write('DONE\n\n', null);
} catch(e) { } catch (e) {
logError(e, 'internal error while writing connection to helper'); logError(e, 'internal error while writing connection to helper');
this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR); this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR);
@ -619,7 +619,7 @@ var NetworkAgent = class {
try { try {
let monitor = this._pluginDir.monitor(Gio.FileMonitorFlags.NONE, null); let monitor = this._pluginDir.monitor(Gio.FileMonitorFlags.NONE, null);
monitor.connect('changed', () => { this._vpnCacheBuilt = false; }); monitor.connect('changed', () => { this._vpnCacheBuilt = false; });
} catch(e) { } catch (e) {
log('Failed to create monitor for VPN plugin dir: ' + e.message); log('Failed to create monitor for VPN plugin dir: ' + e.message);
} }
@ -631,7 +631,7 @@ var NetworkAgent = class {
try { try {
this._native.init_finish(res); this._native.init_finish(res);
this._initialized = true; this._initialized = true;
} catch(e) { } catch (e) {
this._native = null; this._native = null;
logError(e, 'error initializing the NetworkManager Agent'); logError(e, 'error initializing the NetworkManager Agent');
} }

View File

@ -342,7 +342,7 @@ var AuthenticationAgent = class {
enable() { enable() {
try { try {
this._native.register(); this._native.register();
} catch(e) { } catch (e) {
log('Failed to register AuthenticationAgent'); log('Failed to register AuthenticationAgent');
} }
} }
@ -350,7 +350,7 @@ var AuthenticationAgent = class {
disable() { disable() {
try { try {
this._native.unregister(); this._native.unregister();
} catch(e) { } catch (e) {
log('Failed to unregister AuthenticationAgent'); log('Failed to unregister AuthenticationAgent');
} }
} }

View File

@ -8,7 +8,7 @@ var Tpl = null;
var Tp = null; var Tp = null;
try { try {
({ TelepathyGLib: Tp, TelepathyLogger: Tpl } = imports.gi); ({ TelepathyGLib: Tp, TelepathyLogger: Tpl } = imports.gi);
} catch(e) { } catch (e) {
log('Telepathy is not available, chat integration will be disabled.'); log('Telepathy is not available, chat integration will be disabled.');
} }

View File

@ -155,7 +155,7 @@ function findAppFromInhibitor(inhibitor) {
let desktopFile; let desktopFile;
try { try {
[desktopFile] = inhibitor.GetAppIdSync(); [desktopFile] = inhibitor.GetAppIdSync();
} catch(e) { } catch (e) {
// XXX -- sometimes JIT inhibitors generated by gnome-session // XXX -- sometimes JIT inhibitors generated by gnome-session
// get removed too soon. Don't fail in this case. // get removed too soon. Don't fail in this case.
log('gnome-session gave us a dead inhibitor: %s'.format(inhibitor.get_object_path())); log('gnome-session gave us a dead inhibitor: %s'.format(inhibitor.get_object_path()));
@ -335,7 +335,7 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
try { try {
this._updatesPermission = Polkit.Permission.new_sync("org.freedesktop.packagekit.trigger-offline-update", null, null); this._updatesPermission = Polkit.Permission.new_sync("org.freedesktop.packagekit.trigger-offline-update", null, null);
} catch(e) { } catch (e) {
log('No permission to trigger offline updates: %s'.format(e.toString())); log('No permission to trigger offline updates: %s'.format(e.toString()));
} }

View File

@ -114,7 +114,7 @@ function init() {
return base.replace(/\]$/, ' delegate for ' + this.actor.toString().substring(1)); return base.replace(/\]$/, ' delegate for ' + this.actor.toString().substring(1));
else else
return base; return base;
} catch(e) { } catch (e) {
return base; return base;
} }
}; };

View File

@ -127,7 +127,7 @@ function updateExtension(uuid) {
try { try {
extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, ExtensionUtils.ExtensionType.PER_USER); extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, ExtensionUtils.ExtensionType.PER_USER);
ExtensionSystem.loadExtension(extension); ExtensionSystem.loadExtension(extension);
} catch(e) { } catch (e) {
if (extension) if (extension)
ExtensionSystem.unloadExtension(extension); ExtensionSystem.unloadExtension(extension);
@ -234,7 +234,7 @@ class InstallExtensionDialog extends ModalDialog.ModalDialog {
try { try {
let extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER); let extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
ExtensionSystem.loadExtension(extension); ExtensionSystem.loadExtension(extension);
} catch(e) { } catch (e) {
uninstallExtension(uuid); uninstallExtension(uuid);
errback('LoadExtensionError', e); errback('LoadExtensionError', e);
return; return;

View File

@ -64,7 +64,7 @@ function disableExtension(uuid) {
let uuid = orderReversed[i]; let uuid = orderReversed[i];
try { try {
ExtensionUtils.extensions[uuid].stateObj.disable(); ExtensionUtils.extensions[uuid].stateObj.disable();
} catch(e) { } catch (e) {
logExtensionError(uuid, e); logExtensionError(uuid, e);
} }
} }
@ -77,7 +77,7 @@ function disableExtension(uuid) {
try { try {
extension.stateObj.disable(); extension.stateObj.disable();
} catch(e) { } catch (e) {
logExtensionError(uuid, e); logExtensionError(uuid, e);
} }
@ -85,7 +85,7 @@ function disableExtension(uuid) {
let uuid = order[i]; let uuid = order[i];
try { try {
ExtensionUtils.extensions[uuid].stateObj.enable(); ExtensionUtils.extensions[uuid].stateObj.enable();
} catch(e) { } catch (e) {
logExtensionError(uuid, e); logExtensionError(uuid, e);
} }
} }
@ -132,7 +132,7 @@ function enableExtension(uuid) {
extension.state = ExtensionState.ENABLED; extension.state = ExtensionState.ENABLED;
_signals.emit('extension-state-changed', extension); _signals.emit('extension-state-changed', extension);
return; return;
} catch(e) { } catch (e) {
if (extension.stylesheet) { if (extension.stylesheet) {
theme.unload_stylesheet(extension.stylesheet); theme.unload_stylesheet(extension.stylesheet);
delete extension.stylesheet; delete extension.stylesheet;
@ -208,7 +208,7 @@ function reloadExtension(oldExtension) {
let newExtension; let newExtension;
try { try {
newExtension = ExtensionUtils.createExtensionObject(uuid, dir, type); newExtension = ExtensionUtils.createExtensionObject(uuid, dir, type);
} catch(e) { } catch (e) {
logExtensionError(uuid, e); logExtensionError(uuid, e);
return; return;
} }
@ -235,7 +235,7 @@ function initExtension(uuid) {
ExtensionUtils.installImporter(extension); ExtensionUtils.installImporter(extension);
try { try {
extensionModule = extension.imports.extension; extensionModule = extension.imports.extension;
} catch(e) { } catch (e) {
logExtensionError(uuid, e); logExtensionError(uuid, e);
return false; return false;
} }
@ -243,7 +243,7 @@ function initExtension(uuid) {
if (extensionModule.init) { if (extensionModule.init) {
try { try {
extensionState = extensionModule.init(extension); extensionState = extensionModule.init(extension);
} catch(e) { } catch (e) {
logExtensionError(uuid, e); logExtensionError(uuid, e);
return false; return false;
} }

View File

@ -181,7 +181,7 @@ var CandidatePopup = class CandidatePopup {
let window = global.display.focus_window.get_compositor_private(); let window = global.display.focus_window.get_compositor_private();
this._setDummyCursorGeometry(window.x + x, window.y + y, w, h); this._setDummyCursorGeometry(window.x + x, window.y + y, w, h);
}); });
} catch(e) { } catch (e) {
// Only recent IBus versions have support for this signal // Only recent IBus versions have support for this signal
// which is used for wayland clients. In order to work // which is used for wayland clients. In order to work
// with older IBus versions we can silently ignore the // with older IBus versions we can silently ignore the

View File

@ -798,7 +798,7 @@ var ZoomRegion = class ZoomRegion {
let extents; let extents;
try { try {
extents = component.get_extents(Atspi.CoordType.SCREEN); extents = component.get_extents(Atspi.CoordType.SCREEN);
} catch(e) { } catch (e) {
log('Failed to read extents of focused component: ' + e.message); log('Failed to read extents of focused component: ' + e.message);
return; return;
} }
@ -815,7 +815,7 @@ var ZoomRegion = class ZoomRegion {
let extents; let extents;
try { try {
extents = text.get_character_extents(text.get_caret_offset(), 0); extents = text.get_character_extents(text.get_caret_offset(), 0);
} catch(e) { } catch (e) {
log('Failed to read extents of text caret: ' + e.message); log('Failed to read extents of text caret: ' + e.message);
return; return;
} }

View File

@ -759,7 +759,7 @@ var GtkNotificationDaemon = class GtkNotificationDaemon {
let source; let source;
try { try {
source = this._ensureAppSource(appId); source = this._ensureAppSource(appId);
} catch(e) { } catch (e) {
if (e instanceof InvalidAppError) if (e instanceof InvalidAppError)
return; return;
throw e; throw e;
@ -793,7 +793,7 @@ var GtkNotificationDaemon = class GtkNotificationDaemon {
let source; let source;
try { try {
source = this._ensureAppSource(appId); source = this._ensureAppSource(appId);
} catch(e) { } catch (e) {
if (e instanceof InvalidAppError) { if (e instanceof InvalidAppError) {
invocation.return_dbus_error('org.gtk.Notifications.InvalidApp', 'The app by ID "%s" could not be found'.format(appId)); invocation.return_dbus_error('org.gtk.Notifications.InvalidApp', 'The app by ID "%s" could not be found'.format(appId));
return; return;

View File

@ -69,7 +69,7 @@ function loadRemoteSearchProviders(searchSettings, callback) {
try { try {
keyfile.load_from_file(path, 0); keyfile.load_from_file(path, 0);
} catch(e) { } catch (e) {
return; return;
} }
@ -99,7 +99,7 @@ function loadRemoteSearchProviders(searchSettings, callback) {
let autoStart = true; let autoStart = true;
try { try {
autoStart = keyfile.get_boolean(group, 'AutoStart'); autoStart = keyfile.get_boolean(group, 'AutoStart');
} catch(e) { } catch (e) {
// ignore error // ignore error
} }
@ -118,13 +118,13 @@ function loadRemoteSearchProviders(searchSettings, callback) {
remoteProvider.defaultEnabled = true; remoteProvider.defaultEnabled = true;
try { try {
remoteProvider.defaultEnabled = !keyfile.get_boolean(group, 'DefaultDisabled'); remoteProvider.defaultEnabled = !keyfile.get_boolean(group, 'DefaultDisabled');
} catch(e) { } catch (e) {
// ignore error // ignore error
} }
objectPaths[objectPath] = remoteProvider; objectPaths[objectPath] = remoteProvider;
loadedProviders.push(remoteProvider); loadedProviders.push(remoteProvider);
} catch(e) { } catch (e) {
log('Failed to add search provider %s: %s'.format(path, e.toString())); log('Failed to add search provider %s: %s'.format(path, e.toString()));
} }
} }

View File

@ -120,7 +120,7 @@ function _loadMode(file, info) {
if (fileContent instanceof Uint8Array) if (fileContent instanceof Uint8Array)
fileContent = imports.byteArray.toString(fileContent); fileContent = imports.byteArray.toString(fileContent);
newMode = JSON.parse(fileContent); newMode = JSON.parse(fileContent);
} catch(e) { } catch (e) {
return; return;
} }

View File

@ -199,7 +199,7 @@ var InputSourceSystemSettings = class extends InputSourceSettings {
let props; let props;
try { try {
props = conn.call_finish(result).deep_unpack()[0]; props = conn.call_finish(result).deep_unpack()[0];
} catch(e) { } catch (e) {
log('Could not get properties from ' + this._BUS_NAME); log('Could not get properties from ' + this._BUS_NAME);
return; return;
} }

View File

@ -1981,7 +1981,7 @@ var NMApplet = class extends PanelMenu.SystemIndicator {
let state = client.check_connectivity_finish(result); let state = client.check_connectivity_finish(result);
if (state >= NM.ConnectivityState.FULL) if (state >= NM.ConnectivityState.FULL)
this._closeConnectivityCheck(path); this._closeConnectivityCheck(path);
} catch(e) { } } catch (e) { }
}); });
} else { } else {
log('Invalid result from portal helper: ' + result); log('Invalid result from portal helper: ' + result);

View File

@ -67,7 +67,7 @@ var Client = class {
_onProxyReady(o, res) { _onProxyReady(o, res) {
try { try {
this._proxy = Gio.DBusProxy.new_finish(res); this._proxy = Gio.DBusProxy.new_finish(res);
} catch(e) { } catch (e) {
log('error creating bolt proxy: %s'.format(e.message)); log('error creating bolt proxy: %s'.format(e.message));
return; return;
} }