Skip to content

Commit 0d0b68a

Browse files
author
laodouya
committed
Show error while server return empty or bad status code
1 parent 8dac66d commit 0d0b68a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/commands/query.py

+6
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ async def query_command(interaction, query, format):
2727
params = {"default_format": format.value}
2828
headers = {"Content-Type": "text/plain;charset=UTF-8"}
2929
response = requests.post(api_url, params=params, data=query, headers=headers)
30+
if response.status_code != 200:
31+
await interaction.followup("Server error with unsupported format, status_code: {0}".format(response.status_code))
32+
return
33+
if len(response.content) == 0:
34+
await interaction.followup("Query error")
35+
return
3036

3137
await interaction.followup(response.content.decode("utf-8"))

0 commit comments

Comments
 (0)