fix: error handling (#3214)

This commit is contained in:
Tiago Vasconcelos 2025-06-24 16:27:28 +01:00 committed by GitHub
parent b1a09af82c
commit 7c0a955b30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 9 deletions

View file

@ -130,14 +130,20 @@ async def api_lnurlscan(
headers = {"User-Agent": settings.user_agent}
async with httpx.AsyncClient(headers=headers, follow_redirects=True) as client:
check_callback_url(url)
try:
r = await client.get(url, timeout=5)
r.raise_for_status()
if r.is_error:
except httpx.HTTPStatusError as exc:
if exc.response.status_code == 404:
raise HTTPException(HTTPStatus.NOT_FOUND, "Not found") from exc
raise HTTPException(
status_code=HTTPStatus.SERVICE_UNAVAILABLE,
detail={"domain": domain, "message": "failed to get parameters"},
)
detail={
"domain": domain,
"message": "failed to get parameters",
},
) from exc
try:
data = json.loads(r.text)
except json.decoder.JSONDecodeError as exc:

View file

@ -338,9 +338,6 @@ window.WalletPageLogic = {
'/api/v1/lnurlscan/' + this.parse.data.request,
this.g.wallet.adminkey
)
.catch(err => {
LNbits.utils.notifyApiError(err)
})
.then(response => {
const data = response.data
@ -378,6 +375,9 @@ window.WalletPageLogic = {
}
}
})
.catch(err => {
LNbits.utils.notifyApiError(err)
})
},
decodeQR(res) {
this.parse.data.request = res[0].rawValue