diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-09-15 11:03:14 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-09-16 12:04:36 +0200 |
| commit | 4cea60889a5a5cd9cefc76df2afc2af612021e7e (patch) | |
| tree | bfbcbd8f3bc40842fa62ac019c7517a91278ec1e /gui/src/renderer | |
| parent | 4d9a8206dcfc5312160a8d0b7066157c8f2a71f4 (diff) | |
| download | mullvadvpn-4cea60889a5a5cd9cefc76df2afc2af612021e7e.tar.xz mullvadvpn-4cea60889a5a5cd9cefc76df2afc2af612021e7e.zip | |
Update catch-statements to work with unknown type
Diffstat (limited to 'gui/src/renderer')
| -rw-r--r-- | gui/src/renderer/app.tsx | 18 | ||||
| -rw-r--r-- | gui/src/renderer/components/ClipboardLabel.tsx | 3 | ||||
| -rw-r--r-- | gui/src/renderer/containers/AdvancedSettingsPage.tsx | 9 | ||||
| -rw-r--r-- | gui/src/renderer/containers/ConnectPage.tsx | 9 | ||||
| -rw-r--r-- | gui/src/renderer/containers/ExpiredAccountErrorViewContainer.tsx | 6 | ||||
| -rw-r--r-- | gui/src/renderer/containers/OpenVPNSettingsPage.tsx | 12 | ||||
| -rw-r--r-- | gui/src/renderer/containers/PreferencesPage.tsx | 3 | ||||
| -rw-r--r-- | gui/src/renderer/containers/SelectLocationPage.tsx | 9 | ||||
| -rw-r--r-- | gui/src/renderer/containers/WireguardSettingsPage.tsx | 6 |
9 files changed, 50 insertions, 25 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index c888480033..296638b205 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -297,7 +297,8 @@ export default class AppRenderer { actions.account.updateAccountToken(accountToken); actions.account.loggedIn(); this.redirectToConnect(); - } catch (error) { + } catch (e) { + const error = e as Error; actions.account.loginFailed(error); } } @@ -306,7 +307,8 @@ export default class AppRenderer { try { await IpcRendererEventChannel.account.logout(); } catch (e) { - log.info('Failed to logout: ', e.message); + const error = e as Error; + log.info('Failed to logout: ', error.message); } } @@ -322,7 +324,8 @@ export default class AppRenderer { const accountExpiry = new Date().toISOString(); actions.account.accountCreated(accountToken, accountExpiry); this.redirectToConnect(); - } catch (error) { + } catch (e) { + const error = e as Error; actions.account.createAccountFailed(error); } } @@ -404,7 +407,8 @@ export default class AppRenderer { try { token = await IpcRendererEventChannel.account.getWwwAuthToken(); } catch (e) { - log.error(`Failed to get the WWW auth token: ${e.message}`); + const error = e as Error; + log.error(`Failed to get the WWW auth token: ${error.message}`); } void this.openUrl(`${link}?token=${token}`); }; @@ -483,7 +487,8 @@ export default class AppRenderer { try { const valid = await IpcRendererEventChannel.wireguardKeys.verifyKey(); actions.settings.completeWireguardKeyVerification(valid); - } catch (error) { + } catch (e) { + const error = e as Error; log.error(`Failed to verify WireGuard key - ${error.message}`); actions.settings.completeWireguardKeyVerification(undefined); } @@ -981,7 +986,8 @@ export default class AppRenderer { if (location && getLocationPromise === this.getLocationPromise) { return location; } - } catch (error) { + } catch (e) { + const error = e as Error; log.error(`Failed to update the location: ${error.message}`); } } diff --git a/gui/src/renderer/components/ClipboardLabel.tsx b/gui/src/renderer/components/ClipboardLabel.tsx index 2131e884df..43b0d2c764 100644 --- a/gui/src/renderer/components/ClipboardLabel.tsx +++ b/gui/src/renderer/components/ClipboardLabel.tsx @@ -50,7 +50,8 @@ export default class ClipboardLabel extends React.Component<IProps, IState> { await navigator.clipboard.writeText(this.props.value); this.scheduler.schedule(() => this.setState({ showsMessage: false }), this.props.delay); this.setState({ showsMessage: true }); - } catch (error) { + } catch (e) { + const error = e as Error; log.error(`Failed to copy to clipboard: ${error.message}`); } }; diff --git a/gui/src/renderer/containers/AdvancedSettingsPage.tsx b/gui/src/renderer/containers/AdvancedSettingsPage.tsx index 8e8acf2ee9..51ba310aad 100644 --- a/gui/src/renderer/containers/AdvancedSettingsPage.tsx +++ b/gui/src/renderer/containers/AdvancedSettingsPage.tsx @@ -53,7 +53,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.updateRelaySettings(relayUpdate); } catch (e) { - log.error('Failed to update tunnel protocol constraints', e.message); + const error = e as Error; + log.error('Failed to update tunnel protocol constraints', error.message); } }, @@ -61,7 +62,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.setEnableIpv6(enableIpv6); } catch (e) { - log.error('Failed to update enable IPv6', e.message); + const error = e as Error; + log.error('Failed to update enable IPv6', error.message); } }, @@ -69,7 +71,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.setBlockWhenDisconnected(blockWhenDisconnected); } catch (e) { - log.error('Failed to update block when disconnected', e.message); + const error = e as Error; + log.error('Failed to update block when disconnected', error.message); } }, diff --git a/gui/src/renderer/containers/ConnectPage.tsx b/gui/src/renderer/containers/ConnectPage.tsx index 2069b4012b..c9ae60897b 100644 --- a/gui/src/renderer/containers/ConnectPage.tsx +++ b/gui/src/renderer/containers/ConnectPage.tsx @@ -80,21 +80,24 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp onConnect: async () => { try { await props.app.connectTunnel(); - } catch (error) { + } catch (e) { + const error = e as Error; log.error(`Failed to connect the tunnel: ${error.message}`); } }, onDisconnect: async () => { try { await props.app.disconnectTunnel(); - } catch (error) { + } catch (e) { + const error = e as Error; log.error(`Failed to disconnect the tunnel: ${error.message}`); } }, onReconnect: async () => { try { await props.app.reconnectTunnel(); - } catch (error) { + } catch (e) { + const error = e as Error; log.error(`Failed to reconnect the tunnel: ${error.message}`); } }, diff --git a/gui/src/renderer/containers/ExpiredAccountErrorViewContainer.tsx b/gui/src/renderer/containers/ExpiredAccountErrorViewContainer.tsx index e5c56e7f28..dc5b12a40e 100644 --- a/gui/src/renderer/containers/ExpiredAccountErrorViewContainer.tsx +++ b/gui/src/renderer/containers/ExpiredAccountErrorViewContainer.tsx @@ -20,7 +20,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp onDisconnect: async () => { try { await props.app.disconnectTunnel(); - } catch (error) { + } catch (e) { + const error = e as Error; log.error(`Failed to disconnect the tunnel: ${error.message}`); } }, @@ -28,7 +29,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.setBlockWhenDisconnected(blockWhenDisconnected); } catch (e) { - log.error('Failed to update block when disconnected', e.message); + const error = e as Error; + log.error('Failed to update block when disconnected', error.message); } }, navigateToRedeemVoucher: () => { diff --git a/gui/src/renderer/containers/OpenVPNSettingsPage.tsx b/gui/src/renderer/containers/OpenVPNSettingsPage.tsx index 378dc9bb82..9212ca68ac 100644 --- a/gui/src/renderer/containers/OpenVPNSettingsPage.tsx +++ b/gui/src/renderer/containers/OpenVPNSettingsPage.tsx @@ -67,7 +67,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.updateRelaySettings(relayUpdate); } catch (e) { - log.error('Failed to update relay settings', e.message); + const error = e as Error; + log.error('Failed to update relay settings', error.message); } }, @@ -84,7 +85,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.updateRelaySettings(relayUpdate); } catch (e) { - log.error('Failed to update relay settings', e.message); + const error = e as Error; + log.error('Failed to update relay settings', error.message); } }, @@ -92,7 +94,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.setBridgeState(bridgeState); } catch (e) { - log.error(`Failed to update bridge state: ${e.message}`); + const error = e as Error; + log.error(`Failed to update bridge state: ${error.message}`); } }, @@ -100,7 +103,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.setOpenVpnMssfix(mssfix); } catch (e) { - log.error('Failed to update mssfix value', e.message); + const error = e as Error; + log.error('Failed to update mssfix value', error.message); } }, }; diff --git a/gui/src/renderer/containers/PreferencesPage.tsx b/gui/src/renderer/containers/PreferencesPage.tsx index a050afedf7..d4176d1ca2 100644 --- a/gui/src/renderer/containers/PreferencesPage.tsx +++ b/gui/src/renderer/containers/PreferencesPage.tsx @@ -30,7 +30,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp setAutoStart: async (autoStart: boolean) => { try { await props.app.setAutoStart(autoStart); - } catch (error) { + } catch (e) { + const error = e as Error; log.error(`Cannot set auto-start: ${error.message}`); } }, diff --git a/gui/src/renderer/containers/SelectLocationPage.tsx b/gui/src/renderer/containers/SelectLocationPage.tsx index ea931c8ea9..cd455a01f6 100644 --- a/gui/src/renderer/containers/SelectLocationPage.tsx +++ b/gui/src/renderer/containers/SelectLocationPage.tsx @@ -65,7 +65,8 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: IHistoryProps & IApp await props.app.updateRelaySettings(relayUpdate); await props.app.connectTunnel(); } catch (e) { - log.error(`Failed to select the exit location: ${e.message}`); + const error = e as Error; + log.error(`Failed to select the exit location: ${error.message}`); } }, onSelectBridgeLocation: async (bridgeLocation: RelayLocation) => { @@ -77,7 +78,8 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: IHistoryProps & IApp new BridgeSettingsBuilder().location.fromRaw(bridgeLocation).build(), ); } catch (e) { - log.error(`Failed to select the bridge location: ${e.message}`); + const error = e as Error; + log.error(`Failed to select the bridge location: ${error.message}`); } }, onSelectClosestToExit: async () => { @@ -87,7 +89,8 @@ const mapDispatchToProps = (dispatch: ReduxDispatch, props: IHistoryProps & IApp try { await props.app.updateBridgeSettings(new BridgeSettingsBuilder().location.any().build()); } catch (e) { - log.error(`Failed to set the bridge location to closest to exit: ${e.message}`); + const error = e as Error; + log.error(`Failed to set the bridge location to closest to exit: ${error.message}`); } }, onClearProviders: async () => { diff --git a/gui/src/renderer/containers/WireguardSettingsPage.tsx b/gui/src/renderer/containers/WireguardSettingsPage.tsx index cf7833d116..5e6c27105e 100644 --- a/gui/src/renderer/containers/WireguardSettingsPage.tsx +++ b/gui/src/renderer/containers/WireguardSettingsPage.tsx @@ -65,7 +65,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.updateRelaySettings(relayUpdate); } catch (e) { - log.error('Failed to update relay settings', e.message); + const error = e as Error; + log.error('Failed to update relay settings', error.message); } }, @@ -73,7 +74,8 @@ const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAp try { await props.app.setWireguardMtu(mtu); } catch (e) { - log.error('Failed to update mtu value', e.message); + const error = e as Error; + log.error('Failed to update mtu value', error.message); } }, |
