Skip to content

Commit 12ea416

Browse files
committed
chore: improve turnkey fail to get session error handling
1 parent ac2df06 commit 12ea416

File tree

1 file changed

+8
-7
lines changed
  • packages/wallets/wallet-turnkey/src/strategy/turnkey

1 file changed

+8
-7
lines changed

packages/wallets/wallet-turnkey/src/strategy/turnkey/turnkey.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,10 @@ export class TurnkeyWallet {
135135
session,
136136
organizationId: actualOrganizationId,
137137
}
138-
} catch (e: any) {
139-
throw new WalletException(new Error(e.message), {
140-
code: UnspecifiedErrorCode,
141-
type: ErrorType.WalletError,
142-
contextModule: 'turnkey-wallet-get-session',
143-
})
138+
} catch {
139+
throw new TurnkeyWalletSessionException(
140+
new Error('Session expired. Please login again.'),
141+
)
144142
}
145143
}
146144

@@ -240,6 +238,7 @@ export class TurnkeyWallet {
240238
bundle: credentialBundle,
241239
expirationSeconds,
242240
})
241+
243242
await iframeClient.refreshSession({
244243
sessionType: SessionType.READ_WRITE,
245244
targetPublicKey: iframeClient.iframePublicKey,
@@ -248,7 +247,9 @@ export class TurnkeyWallet {
248247

249248
const session = await this.turnkey?.getSession()
250249
if (!session) {
251-
throw new WalletException(new Error('Failed to refresh session'))
250+
throw new TurnkeyWalletSessionException(
251+
new Error('Session expired. Please login again.'),
252+
)
252253
}
253254

254255
this.organizationId = session.organizationId

0 commit comments

Comments
 (0)