exit with error code 1 on fatal errors
This commit is contained in:
@ -54,7 +54,8 @@ async def main():
|
|||||||
try:
|
try:
|
||||||
user = (await response.json())["id"]
|
user = (await response.json())["id"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
sys.exit("User ID not found in JSON response. Actual JSON response: " + json.dumps(await response.json(), indent=4))
|
print("User ID not found in JSON response. Actual JSON response: " + json.dumps(await response.json(), indent=4))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# looping to fill up list of messages by requesting batches of messages from the API and adding them to the list
|
# looping to fill up list of messages by requesting batches of messages from the API and adding them to the list
|
||||||
while True:
|
while True:
|
||||||
@ -74,7 +75,8 @@ async def main():
|
|||||||
print("Channel is not yet indexed. Waiting for " + str((await response.json())["retry_after"]) + "s as requested by the Discord API")
|
print("Channel is not yet indexed. Waiting for " + str((await response.json())["retry_after"]) + "s as requested by the Discord API")
|
||||||
await asyncio.sleep((await response.json())["retry_after"])
|
await asyncio.sleep((await response.json())["retry_after"])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
sys.exit("Unexpected JSON response received from Discord after trying to search for messages. Actual JSON response: " + json.dumps(await response.json(), indent=4))
|
print("Unexpected JSON response received from Discord after trying to search for messages. Actual JSON response: " + json.dumps(await response.json(), indent=4))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# if the batch is not empty, adding the messages in batch to the list of messages to be deleted
|
# if the batch is not empty, adding the messages in batch to the list of messages to be deleted
|
||||||
if batch:
|
if batch:
|
||||||
@ -105,7 +107,8 @@ async def main():
|
|||||||
|
|
||||||
# otherwise, printing out json response and aborting
|
# otherwise, printing out json response and aborting
|
||||||
else:
|
else:
|
||||||
sys.exit("Unexpected HTTP status code received. Actual response: " + json.dumps(await response.json(), indent=4))
|
print("Unexpected HTTP status code received. Actual response: " + json.dumps(await response.json(), indent=4))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user