mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Add better error logging
This commit is contained in:
parent
4dd922c94f
commit
601137f81a
1 changed files with 22 additions and 0 deletions
|
@ -1970,6 +1970,28 @@ class OtherCog(commands.Cog):
|
|||
|
||||
msg = await ctx.respond(embed=embed, ephemeral=False)
|
||||
async with httpx.AsyncClient(base_url=f"http://{host}/api", follow_redirects=True) as client:
|
||||
try:
|
||||
response = await client.get("/tags")
|
||||
response.raise_for_status()
|
||||
except httpx.HTTPStatusError as e:
|
||||
error = "GET {0.response.url} HTTP {0.status}: {0.text}".format(e.response)
|
||||
return await msg.edit(
|
||||
embed=discord.Embed(
|
||||
title="Failed to GET /tags. Offline?",
|
||||
description=error,
|
||||
colour=discord.Colour.red()
|
||||
)
|
||||
)
|
||||
except httpx.TransportError as e:
|
||||
return await msg.edit(
|
||||
embed=discord.Embed(
|
||||
title=f"Failed to connect to {host!r}",
|
||||
description="Transport error sending request to {}: {}".format(
|
||||
host, str(e)
|
||||
),
|
||||
colour=discord.Colour.red()
|
||||
)
|
||||
)
|
||||
# get models
|
||||
try:
|
||||
response = await client.post("/show", json={"name": model})
|
||||
|
|
Loading…
Reference in a new issue