Add Error Handling when upload folder is empty

This commit is contained in:
Nico Jensen 2023-10-30 12:46:08 +01:00
parent a4c5920e68
commit 5cb99e07b6

View File

@ -104,6 +104,8 @@ def createNewPost(access_token, url, ImageID, ImageDescription):
def sendImages(Token, url, imagedir, uploadType, deleteFile): def sendImages(Token, url, imagedir, uploadType, deleteFile):
files = getImages(imagedir) files = getImages(imagedir)
if not files:
raise ValueError("No file found.")
tags = getTags("tags.txt") tags = getTags("tags.txt")
tagDescription = "" tagDescription = ""
newFileID = "" newFileID = ""
@ -141,4 +143,7 @@ if __name__ == "__main__":
uploadType = config.get("upload_type") uploadType = config.get("upload_type")
deleteFile = config.get("delete_file") deleteFile = config.get("delete_file")
sendImages(accessToken, url, imagedir, uploadType, deleteFile) try:
sendImages(accessToken, url, imagedir, uploadType, deleteFile)
except ValueError as e:
print(f"Error while uploading the image: {e}")