diff --git a/CHANGELOG.md b/CHANGELOG.md index de8288a6..ac6b34e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- changed: Log unknown swap errors as a crash. + ## 2.19.1 (2024-10-24) - fixed: Barcode login works again. diff --git a/src/core/swap/swap-api.ts b/src/core/swap/swap-api.ts index 74b92024..97704028 100644 --- a/src/core/swap/swap-api.ts +++ b/src/core/swap/swap-api.ts @@ -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 } ) @@ -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 +}