From c1689da3c4381b05c70b7330eb61d67e227a4408 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Sun, 15 Nov 2015 13:33:21 -0800 Subject: [PATCH] (#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. --- lib/vmfloaty/http.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/vmfloaty/http.rb b/lib/vmfloaty/http.rb index bd1cc30..07a8a2d 100644 --- a/lib/vmfloaty/http.rb +++ b/lib/vmfloaty/http.rb @@ -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|