add explicit error messages

This commit is contained in:
horhik 2021-09-07 12:34:29 +03:00
parent 2710d025db
commit 95e8420471
5 changed files with 20 additions and 21 deletions

View file

@ -14,8 +14,8 @@ def try_to_get_carousel(array, post):
return urls
print(Fore.GREEN + "🎠 > Found carousel!")
print(Style.RESET_ALL)
except:
print(Fore.RED + "🎠💥 > No carousel :( ")
except Exception as e:
print(Fore.RED + "🎠💥 > No carousel :( \n", e)
print(Style.RESET_ALL)
return array

View file

@ -17,9 +17,9 @@ def get_image(url):
print(Style.RESET_ALL)
return response.content
except:
except Exception as e:
print(Fore.RED + "💥 > Failed to download image.")
print(Fore.RED + "💥 > Failed to download image. \n", e)
print(Style.RESET_ALL)
@ -31,27 +31,26 @@ def upload_image_to_mastodon(url, mastodon):
print(Fore.GREEN + "✨ > Uploaded!")
print(Style.RESET_ALL)
return media["id"]
except:
print(Fore.RED + "💥 > failed to upload image to mastodon")
except Exception as e:
print(Fore.RED + "💥 > failed to upload image to mastodon. \n", e)
print(Style.RESET_ALL)
def toot(urls, title, mastodon, fetched_user ):
#try:
print(Fore.YELLOW + "🐘 > Creating Toot...", title)
print(Style.RESET_ALL)
ids = []
for url in urls:
ids.append(upload_image_to_mastodon(url, mastodon))
print(url)
post_text = str(title) + "\n" + "crosposted from https://instagram.com/"+fetched_user # creating post text
post_text = post_text[0:1000]
print(ids)
mastodon.status_post(post_text, media_ids = ids)
try:
print(Fore.YELLOW + "🐘 > Creating Toot...", title)
print(Style.RESET_ALL)
ids = []
for url in urls:
ids.append(upload_image_to_mastodon(url, mastodon))
print(url)
post_text = str(title) + "\n" + "crosposted from https://instagram.com/"+fetched_user # creating post text
post_text = post_text[0:1000]
print(ids)
mastodon.status_post(post_text, media_ids = ids)
#except:
# print(urls)
# print(Fore.RED + "😿 > Failed to create toot")
# print(Style.RESET_ALL)
except Exception as e:
print(Fore.RED + "😿 > Failed to create toot \n", e)
print(Style.RESET_ALL)
def get_new_posts(mastodon, profile, mastodon_carousel_size, post_limit, already_posted_path, using_mastodon, carousel_size, post_interval, fetched_user):
posts = profile.get_posts()