From 611b4881d93a87255ceb1c2bc3d678537eff539b Mon Sep 17 00:00:00 2001 From: pierre Date: Wed, 22 Jan 2025 20:53:57 +0100 Subject: [PATCH] catch wrong daemon error mapping workaround --- nym-vpn-app/src/state/init.ts | 14 ++++++++++++++ nym-vpn-app/src/state/useTauriEvents.ts | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/nym-vpn-app/src/state/init.ts b/nym-vpn-app/src/state/init.ts index 2c64bb9d1f..8f730ce2be 100644 --- a/nym-vpn-app/src/state/init.ts +++ b/nym-vpn-app/src/state/init.ts @@ -77,6 +77,20 @@ export async function initFirstBatch( onFulfilled: ({ state, error }) => { dispatch({ type: 'update-connection-state', state }); if (error) { + // TODO remove this dirty hack once switched to the new tunnel API + if ( + error.key === 'CSDaemonInternal' && + error.data?.reason.includes('SameEntryAndExitGateway') + ) { + dispatch({ + type: 'set-error', + error: { + key: 'CStateGwDirSameEntryAndExitGw', + message: 'Cannot connect to the same entry and exit gateway', + }, + }); + return; + } dispatch({ type: 'set-error', error }); } }, diff --git a/nym-vpn-app/src/state/useTauriEvents.ts b/nym-vpn-app/src/state/useTauriEvents.ts index 57a2e379a0..0db705f35f 100644 --- a/nym-vpn-app/src/state/useTauriEvents.ts +++ b/nym-vpn-app/src/state/useTauriEvents.ts @@ -32,6 +32,20 @@ function handleError(dispatch: StateDispatch, error?: BackendError | null) { return; } console.log('received backend error:', error); + // TODO remove this dirty hack once switched to the new tunnel API + if ( + error.key === 'CSDaemonInternal' && + error.data?.reason.includes('SameEntryAndExitGateway') + ) { + dispatch({ + type: 'set-error', + error: { + key: 'CStateGwDirSameEntryAndExitGw', + message: 'Cannot connect to the same entry and exit gateway', + }, + }); + return; + } dispatch({ type: 'set-error', error }); }