Skip to content

Commit

Permalink
fix: extend sdk error
Browse files Browse the repository at this point in the history
  • Loading branch information
xstelea committed Jul 26, 2024
1 parent 6683d23 commit 55ee090
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 0 additions & 1 deletion examples/simple-dapp/public/.well-known/radix.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"callbackPath": "/connect",
"dApps": [
{
"dAppDefinitionAddress": "account_tdx_2_12yf9gd53yfep7a669fv2t3wm7nz9zeezwd04n02a433ker8vza6rhe"
Expand Down
2 changes: 2 additions & 0 deletions packages/dapp-toolkit/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ export const SdkError = (
error: string,
interactionId: string,
message?: string,
jsError?: unknown,
) => ({
error,
interactionId,
message: message || defaultErrorMessage.get(error) || '',
jsError,
})
23 changes: 21 additions & 2 deletions packages/dapp-toolkit/src/modules/gateway/gateway.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ export const GatewayModule = (input: {
retry.withBackoff$.pipe(
switchMap((result) => {
if (result.isErr())
return [err(SdkError('failedToPollSubmittedTransaction', ''))]
return [
err(
SdkError('failedToPollSubmittedTransaction', '', undefined, {
error: result.error,
context:
'GatewayModule.pollTransactionStatus.retry.withBackoff$',
transactionIntentHash,
}),
),
]

logger?.debug(`pollingTxStatus retry #${result.value + 1}`)

Expand All @@ -56,7 +65,17 @@ export const GatewayModule = (input: {
})
.mapErr((response) => {
logger?.debug(response)
return SdkError('failedToPollSubmittedTransaction', '')
return SdkError(
'failedToPollSubmittedTransaction',
'',
undefined,
{
error: response,
transactionIntentHash,
context:
'GatewayModule.pollTransactionStatus.getTransactionStatus',
},
)
})
}),
filter(
Expand Down

0 comments on commit 55ee090

Please sign in to comment.