You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have spent a real amount of time getting things to work in my personal setup. I think that an improved
error handling in lnbits can spare other people a lot of time. Examplary i will focus only on the Wallet
Connection as this was one major points i struggeled with.
When lnbits is started the method check_funding_source is called. In there the function check_wallet_status. This function receives an error message if something is going wrong.
def check_funding_source(app: QuartTrio) -> None:
@app.before_serving
async def check_wallet_status():
error_message, balance = await WALLET.status()
if error_message:
warnings.warn(
f" × The backend for {WALLET.__class__.__name__} isn't working properly: '{error_message}'",
RuntimeWarning,
)
However, it is not stating what exactly is going wrong, as can be seen here:
async def status(self) -> StatusResponse:
try:
async with httpx.AsyncClient(verify=self.cert) as client:
r = await client.get(
f"{self.endpoint}/v1/balance/channels",
headers=self.auth,
)
except (httpx.ConnectError, httpx.RequestError):
return StatusResponse(f"Unable to connect to {self.endpoint}.", 0)
try:
data = r.json()
if r.is_error:
raise Exception
except Exception:
return StatusResponse(r.text[:200], 0)
return StatusResponse(None, int(data["balance"]) * 1000)
The exception catches (httpx.ConnectError, httpx.RequestError) but is not catching the error itself, like
for instance unauthorized, wrong ssl certificated, connection refused, connection timeout to name just a few: currently the code only returns:
return StatusResponse(f"Unable to connect to {self.endpoint}.", 0)
As a result it makes a hard time for someone trying to debug the issue.
Better:
Grab also the error created from the httpx library and return it at least in the daemon print area or better
in a debug logfile.
The text was updated successfully, but these errors were encountered:
I have spent a real amount of time getting things to work in my personal setup. I think that an improved
error handling in lnbits can spare other people a lot of time. Examplary i will focus only on the Wallet
Connection as this was one major points i struggeled with.
When lnbits is started the method check_funding_source is called. In there the function check_wallet_status. This function receives an error message if something is going wrong.
However, it is not stating what exactly is going wrong, as can be seen here:
The exception catches (httpx.ConnectError, httpx.RequestError) but is not catching the error itself, like
for instance unauthorized, wrong ssl certificated, connection refused, connection timeout to name just a few: currently the code only returns:
return StatusResponse(f"Unable to connect to {self.endpoint}.", 0)
As a result it makes a hard time for someone trying to debug the issue.
Better:
Grab also the error created from the httpx library and return it at least in the daemon print area or better
in a debug logfile.
The text was updated successfully, but these errors were encountered: