Skip to content

Commit

Permalink
Merge pull request #55 from highb/add_handling_for_failed_modify_request
Browse files Browse the repository at this point in the history
Update pooler provider to throw an exception if the API returns non-OK
  • Loading branch information
briancain authored Dec 5, 2019
2 parents 6954321 + 17c1867 commit 7d0a725
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/vmfloaty/pooler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ def self.modify(verbose, url, hostname, token, modify_hash)
end

res_body = JSON.parse(response.body)
res_body

if res_body['ok']
res_body
elsif response.status == 401
raise AuthError, "HTTP #{response.status}: The token provided could not authenticate to the pooler.\n#{res_body}"
else
raise ModifyError, "HTTP #{response.status}: Failed to modify VMs from the pooler vm/#{hostname}. #{res_body}"
end
end

def self.disk(verbose, url, hostname, token, disk)
Expand Down

0 comments on commit 7d0a725

Please sign in to comment.