diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-06-13 15:01:30 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-06-14 11:22:29 -0300 |
| commit | 77d12c299d284897de242a141d16609799675a3b (patch) | |
| tree | 0eab8f3bd12f79eafb99aa7f507c6515cab35c13 | |
| parent | 2ade9a84077d79863e4a870d44ff0b5458bcf8b6 (diff) | |
| download | mullvadvpn-77d12c299d284897de242a141d16609799675a3b.tar.xz mullvadvpn-77d12c299d284897de242a141d16609799675a3b.zip | |
Separate handled errors by type
| -rw-r--r-- | app/lib/backend.js | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js index c9f9969af3..89b8945962 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -2,6 +2,7 @@ import { log } from '../lib/platform'; import { IpcFacade, RealIpc } from './ipc-facade'; +import { JsonRpcError, TimeOutError } from './jsonrpc-ws-ipc'; import accountActions from '../redux/account/actions'; import connectionActions from '../redux/connection/actions'; import settingsActions from '../redux/settings/actions'; @@ -194,10 +195,7 @@ export class Backend { _rpcErrorToBackendError(e) { if (e instanceof BackendError) { return e; - } - - const isJsonRpcError = e.hasOwnProperty('code'); - if (isJsonRpcError) { + } else if (e instanceof JsonRpcError) { switch (e.code) { case -200: // Account doesn't exist return new BackendError('INVALID_ACCOUNT'); @@ -208,9 +206,7 @@ export class Backend { // for now. return new BackendError('COMMUNICATION_FAILURE'); } - } - - if (e.name === 'TimeOutError') { + } else if (e instanceof TimeOutError) { return new BackendError('COMMUNICATION_FAILURE'); } |
