Improved response checking in linux script
Added check that prevents throwing a JSON parsing error when the server is down
This commit is contained in:
parent
c89bd9c654
commit
1d8f588d48
1 changed files with 8 additions and 0 deletions
|
@ -30,6 +30,14 @@ EOF
|
|||
|
||||
upload() {
|
||||
RESPONSE="$(curl -F "token={{ token }}" -F "upload=@${1}" {{ upload_url }})";
|
||||
|
||||
if jq -e . >/dev/null 2>&1 <<<"$RESPONSE"; then
|
||||
# Response is JSON
|
||||
echo;
|
||||
else
|
||||
notify-send "Error: Uploading returned unexpected response" "Response: ${RESPONSE}";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [[ "$(echo "${RESPONSE}" | jq -r '.message')" == "OK." ]]; then
|
||||
URL="$(echo "${RESPONSE}" | jq -r '.url')";
|
||||
|
|
Loading…
Add table
Reference in a new issue