Skip to content

Commit

Permalink
Log unknown swap errors
Browse files Browse the repository at this point in the history
  • Loading branch information
samholmes committed Oct 25, 2024
1 parent b9f2b81 commit 0fefaa4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- changed: Log unknown swap errors as a crash.

## 2.19.1 (2024-10-24)

- fixed: Barcode login works again.
Expand Down
22 changes: 22 additions & 0 deletions src/core/swap/swap-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ export async function fetchSwapQuotes(
error => {
pendingIds.delete(pluginId)
log.warn(`${pluginId} gave swap error: ${String(error)}`)
// Log unknown errors:
if (isUnknownSwapError(error)) {
log.crash(`Unknown swap error: ${String(error)}`, {
error,
swapPluginId: pluginId,
request: {
// Stringify to include "null"
fromToken: String(request.fromTokenId),
fromWalletType: request.fromWallet.type,
// Stringify to include "null"
toToken: String(request.toTokenId),
toWalletType: request.toWallet.type,
quoteFor: request.quoteFor
}
})
}
throw error
}
)
Expand Down Expand Up @@ -232,3 +248,9 @@ function rankError(error: unknown): number {
if (asMaybeSwapCurrencyError(error) != null) return 2
return 1
}

function isUnknownSwapError(error: unknown): boolean {
const isKnownError = rankError(error) > 1
// NOTE: Add more error filtering here as we decide to filter out noise.
return !isKnownError
}

0 comments on commit 0fefaa4

Please sign in to comment.