Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
Added error handling, api_request will now exit if ERRORARRAY isn't e…
Browse files Browse the repository at this point in the history
…mpty
  • Loading branch information
rwky committed Jul 17, 2011
1 parent 63e5be3 commit c295aa3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* Add error handling

7 changes: 7 additions & 0 deletions linode_bash_api
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ fi

RESPONSE=$(curl -s -d "$DATA" "$APIURL")

if [[ $RESPONSE != *\"ERRORARRAY\":\[\]* ]]
then
echo "API ERROR!" >&2
echo "$RESPONSE" | sed 's/.*\(ERRORARRAY[^}]*\).*/\1}]/' >&2
exit 1
fi

if [[ $DATA != *api_responseFormat* ]]
then
RESPONSE=$(echo "$RESPONSE" | sed 's/,/ /g' | sed 's/\([{}]\)/ \1 /g')
Expand Down

0 comments on commit c295aa3

Please sign in to comment.