mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05: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
|
class Http
|
||||||
def self.get_conn(verbose, url)
|
def self.get_conn(verbose, url)
|
||||||
if url.nil?
|
if url.nil?
|
||||||
STDERR.puts "The url you provided was empty"
|
raise "Did not provide a url to connect to"
|
||||||
exit 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
conn = Faraday.new(:url => url, :ssl => {:verify => false}) do |faraday|
|
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)
|
def self.get_conn_with_auth(verbose, url, user, password)
|
||||||
if url.nil?
|
if url.nil?
|
||||||
STDERR.puts "The url you provided was empty"
|
raise "Did not provide a url to connect to"
|
||||||
exit 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if user.nil?
|
if user.nil?
|
||||||
STDERR.puts "You did not provide a user to authenticate with"
|
raise "You did not provide a user to authenticate with"
|
||||||
exit 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
conn = Faraday.new(:url => url, :ssl => {:verify => false}) do |faraday|
|
conn = Faraday.new(:url => url, :ssl => {:verify => false}) do |faraday|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue