mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-25 21:28:40 -05:00
(#13) Raise exception when required params are missing
Instead of doing a system exit and printing to stderr, raise an exception if parameters are missing when attempting to make an http connection.
This commit is contained in:
parent
3394a14ea0
commit
c1689da3c4
1 changed files with 3 additions and 6 deletions
|
|
@ -3,8 +3,7 @@ require 'faraday'
|
|||
class Http
|
||||
def self.get_conn(verbose, url)
|
||||
if url.nil?
|
||||
STDERR.puts "The url you provided was empty"
|
||||
exit 1
|
||||
raise "Did not provide a url to connect to"
|
||||
end
|
||||
|
||||
conn = Faraday.new(:url => url, :ssl => {:verify => false}) do |faraday|
|
||||
|
|
@ -18,13 +17,11 @@ class Http
|
|||
|
||||
def self.get_conn_with_auth(verbose, url, user, password)
|
||||
if url.nil?
|
||||
STDERR.puts "The url you provided was empty"
|
||||
exit 1
|
||||
raise "Did not provide a url to connect to"
|
||||
end
|
||||
|
||||
if user.nil?
|
||||
STDERR.puts "You did not provide a user to authenticate with"
|
||||
exit 1
|
||||
raise "You did not provide a user to authenticate with"
|
||||
end
|
||||
|
||||
conn = Faraday.new(:url => url, :ssl => {:verify => false}) do |faraday|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue