(#33) Handle more exceptions in vmfloaty command class

This commit adds more handling to the vmfloaty command class that deals
with exceptions thrown from the Pooler class.
This commit is contained in:
Brian Cain 2016-09-24 13:29:43 -07:00
parent 478761023d
commit c62c1c7083
3 changed files with 35 additions and 10 deletions

View file

@ -9,3 +9,9 @@ class TokenError < StandardError
super
end
end
class MissingParamError < StandardError
def initialize(msg="Argument provided to function is missing")
super
end
end

View file

@ -20,6 +20,9 @@ class Pooler
end
def self.retrieve(verbose, os_type, token, url)
# NOTE:
# Developers can use `Utils.generate_os_hash` to
# generate the os_type param.
conn = Http.get_conn(verbose, url)
if token
conn.headers['X-AUTH-TOKEN'] = token
@ -35,7 +38,7 @@ class Pooler
os_string = os_string.chomp("+")
if os_string.size == 0
raise "No operating systems provided to obtain. See `floaty get --help` for more information on how to get VMs."
raise MissingParamError, "No operating systems provided to obtain."
end
response = conn.post "vm/#{os_string}"