diff options
| author | Adam Soltys <[email protected]> | 2025-07-11 09:02:31 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-07-11 09:02:31 -0700 |
| commit | 24de5b9508aef3489fb27a5d3a9cd6de960cbbde (patch) | |
| tree | ab587ab2fa52b3087cc86c98cbb4dc847a3fdc7a /src | |
| parent | 5b458624745c7ea80d1e63c9a6ef77075763ff5f (diff) | |
| download | coinos-ui-24de5b9508aef3489fb27a5d3a9cd6de960cbbde.tar.gz coinos-ui-24de5b9508aef3489fb27a5d3a9cd6de960cbbde.zip | |
catch payment errors
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.server.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.ts b/src/routes/(app)/send/invoice/[id]/+page.server.ts index 4bb7ded5..18379943 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.server.ts +++ b/src/routes/(app)/send/invoice/[id]/+page.server.ts @@ -7,13 +7,20 @@ export async function load({ cookies, depends, params: { id }, parent }) { const { user } = await parent(); const aid = cookies.get("aid") || user.id; - let invoice = await get(`/invoice/${id}`); + const invoice = await get(`/invoice/${id}`); const trust = await get("/trust", auth(cookies)); const trusted = trust.includes(invoice.uid); if (trusted) { - const p = await post("/payments", invoice, auth(cookies)); - redirect(307, `/sent/${p.id}`); + let p; + try { + p = await post("/payments", invoice, auth(cookies)); + } catch (e) { + const { message } = e as Error; + console.log("payment failed", id, e); + error(500, message); + } + if (p) redirect(307, `/sent/${p.id}`); } if (invoice.amount && invoice.prompt && invoice.tip === null) |
