diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 07655087..20583d77 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -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) - r = await client.get(url, timeout=5) - r.raise_for_status() - if r.is_error: + try: + r = await client.get(url, timeout=5) + r.raise_for_status() + 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: diff --git a/lnbits/static/js/wallet.js b/lnbits/static/js/wallet.js index 9d38ab7b..0bbe6974 100644 --- a/lnbits/static/js/wallet.js +++ b/lnbits/static/js/wallet.js @@ -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