From 96555c138a22c1497e73a898032a90136f151924 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Tue, 14 Jan 2025 13:11:47 -0600 Subject: [PATCH] better display rate limiting --- src/components/Faucet.tsx | 7 ++++++- src/components/LnFaucet.tsx | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/Faucet.tsx b/src/components/Faucet.tsx index 7a10018..78a957d 100644 --- a/src/components/Faucet.tsx +++ b/src/components/Faucet.tsx @@ -71,7 +71,12 @@ export function Faucet() { }); if (!res.ok) { - throw new Error(await res.text()); + const text = await res.text(); + if (text.startsWith("")) { + throw new Error("Rate limit exceeded"); + } else { + throw new Error(text); + } } else { let json = await res.json(); return { txid: json.txid, howMuchSats, toAddress: json.address }; diff --git a/src/components/LnFaucet.tsx b/src/components/LnFaucet.tsx index a664504..07a278f 100644 --- a/src/components/LnFaucet.tsx +++ b/src/components/LnFaucet.tsx @@ -73,7 +73,12 @@ export function LnFaucet() { }); if (!res.ok) { - throw new Error(await res.text()); + const text = await res.text(); + if (text.startsWith("")) { + throw new Error("Rate limit exceeded"); + } else { + throw new Error(text); + } } else { return res.json(); }