Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better error handling for invalid config files #22

Open
dyoder opened this issue Apr 4, 2012 · 1 comment
Open

Add better error handling for invalid config files #22

dyoder opened this issue Apr 4, 2012 · 1 comment
Labels
Milestone

Comments

@dyoder
Copy link
Owner

dyoder commented Apr 4, 2012

No description provided.

@automatthew
Copy link
Collaborator

diff --git a/lib/befog/commands/mixins/configurable.rb b/lib/befog/commands/mixins/configurable.rb
index c045376..9374527 100644
--- a/lib/befog/commands/mixins/configurable.rb
+++ b/lib/befog/commands/mixins/configurable.rb
@@ -23,7 +23,19 @@ module Befog
         end

         def _configuration
-          @configuration ||= (YAML.load_file(configuration_path) rescue {})
+          if @configuration
+            @configuration
+          else
+            begin
+              @configuration = YAML.load_file(configuration_path)
+            rescue Errno::ENOENT
+              $stdout.puts "No such file: #{configuration_path}"
+              exit
+            rescue => e
+              $stdout.puts "Problem reading configuration file: #{e.inspect}"
+              exit
+            end
+          end
         end

         def configuration
@@ -43,4 +55,4 @@ module Befog
       end
     end
   end
-end
\ No newline at end of file
+end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants