Skip to content

Commit

Permalink
better display rate limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 14, 2025
1 parent 1627dea commit 96555c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/components/Faucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ export function Faucet() {
});

if (!res.ok) {
throw new Error(await res.text());
const text = await res.text();
if (text.startsWith("<!DOCTYPE html>")) {
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 };
Expand Down
7 changes: 6 additions & 1 deletion src/components/LnFaucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ export function LnFaucet() {
});

if (!res.ok) {
throw new Error(await res.text());
const text = await res.text();
if (text.startsWith("<!DOCTYPE html>")) {
throw new Error("Rate limit exceeded");
} else {
throw new Error(text);
}
} else {
return res.json();
}
Expand Down

0 comments on commit 96555c1

Please sign in to comment.