From 10684fb821aa2fa78f12d9e388d32589b6fa5b63 Mon Sep 17 00:00:00 2001 From: Adam Chambers Date: Tue, 21 Nov 2023 11:22:28 -0500 Subject: [PATCH] chore: try/catch exceptions, skip banks missing data rather than error --- .../src/store/mrgnlendStore.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts b/packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts index fb1628728d..0e76a799b2 100644 --- a/packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts +++ b/packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts @@ -170,12 +170,16 @@ const stateCreator: StateCreator = (set, get) => ({ return; } - const tokenMetadata = getValueInsensitive(tokenMetadataMap, bankMetadata.tokenSymbol); - if (!tokenMetadata) { - return; - } + try { + const tokenMetadata = getValueInsensitive(tokenMetadataMap, bankMetadata.tokenSymbol); + if (!tokenMetadata) { + return; + } - banksWithPriceAndToken.push({ bank, oraclePrice, tokenMetadata }); + banksWithPriceAndToken.push({ bank, oraclePrice, tokenMetadata }); + } catch (err) { + console.error("error fetching token metadata: ", err); + } }); const [extendedBankInfos, extendedBankMetadatas] = banksWithPriceAndToken.reduce( @@ -185,7 +189,9 @@ const stateCreator: StateCreator = (set, get) => ({ let userData; if (wallet?.publicKey) { const tokenAccount = tokenAccountMap!.get(bank.mint.toBase58()); - if (!tokenAccount) throw new Error(`Token account not found for ${bank.mint.toBase58()}`); + if (!tokenAccount) { + return acc; + } userData = { nativeSolBalance, tokenAccount,