From 4e229573911726a2dab98274f54de097604a5bb9 Mon Sep 17 00:00:00 2001 From: Bojan Mojsilovic Date: Thu, 4 Apr 2024 09:40:17 +0200 Subject: [PATCH] Fix lnbc rendering when error is encountered --- src/components/Lnbc/Lnbc.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/Lnbc/Lnbc.tsx b/src/components/Lnbc/Lnbc.tsx index 05ba4ae..c8e83bb 100644 --- a/src/components/Lnbc/Lnbc.tsx +++ b/src/components/Lnbc/Lnbc.tsx @@ -16,7 +16,7 @@ import { sendMessage, subTo } from '../../lib/sockets'; import { APP_ID } from '../../App'; import { signEvent } from '../../lib/nostrAPI'; import Loader from '../Loader/Loader'; -import { logError, logInfo } from '../../lib/logger'; +import { logError, logInfo, logWarning } from '../../lib/logger'; import { useToastContext } from '../Toaster/Toaster'; import { useIntl } from '@cookbook/solid-intl'; import { lnInvoice } from '../../translations'; @@ -35,9 +35,13 @@ const Lnbc: Component< { id?: string, lnbc: string } > = (props) => { const [paymentInProgress, setPaymentInProgress] = createSignal(false); createEffect(() => { - const dec: LnbcInvoice = decode(props.lnbc); - setInvoice(reconcile({...emptyInvoice})) - setInvoice(() => ({ ...dec })); + try { + const dec: LnbcInvoice = decode(props.lnbc); + setInvoice(reconcile({...emptyInvoice})) + setInvoice(() => ({ ...dec })); + } catch (e) { + logError('Failed to decode lightining unvoice: ', e); + } }); createEffect(() => {