Add error handling

This commit is contained in:
Dylan Araps 2016-10-02 22:46:51 +11:00
parent 64693058a7
commit c08fc74607
2 changed files with 7 additions and 3 deletions

View file

@ -407,7 +407,7 @@ scrot_name="neofetch-$(date +%F-%I-%M-%S-${RANDOM}).png"
# Image upload host
# Where to upload the image.
# Possible values: teknik,
image_host="teknik"
image_host="imgur"
# Imgur api key
# This is an api key for neofetch, you can sign up for your own

View file

@ -2315,11 +2315,15 @@ scrot_upload() {
"imgur")
image_url="$(curl -sH "Authorization: Client-ID $imgur_client_id" -F "image=@${image_file}" "https://api.imgur.com/3/upload")"
image_url="$(awk -F 'id:|,' '{printf $2}' <<< "${image_url//\"}")"
image_url="https://i.imgur.com/${image_url}.png"
[ "$image_url" ] && image_url="https://i.imgur.com/${image_url}.png"
;;
esac
[ "$image_url" ] && printf "%s\n" "$image_url"
if [ "$image_url" ]; then
printf "%s\n" "$image_url"
else
printf "%s\n" "[!] Image failed to upload"
fi
}
# }}}