Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Changed LoadError to Fog::Error::LoadError when missing configuration

* When running from command line, rescue the exception, and print the help message

When running fog for the first time with no setup, the missing_exception message
was surrounded above and below with a stack trace, which is not particularly
user-friendly. Since we've rescuing the LoadError only in bin/fog, we know
we don't have to worry about higher level libraries not getting the exception,
since it wouldn't propagate between processes.

Changing LoadError to Fog::Error::LoadError lets us know that this was
an issue on fog's part, rather than some other library we might be
using. Since we inherit from the LoadError class, any higher-level
libraries that were using a rescue based on LoadError will still work.
  • Loading branch information...
commit f3e2c939f40765faa8c4ca29d24d31741c645667 1 parent 0154470
Mark A. Miller authored
Showing with 8 additions and 2 deletions.
  1. +5 −1 bin/fog
  2. +3 −1 lib/fog/core/errors.rb
View
6 bin/fog
@@ -5,7 +5,11 @@ require 'yaml'
Fog.credential = ARGV.first ? ARGV.first.to_sym : nil
Fog.mock! if ENV['FOG_MOCK']
if Fog.credentials.empty?
- Fog::Errors.missing_credentials
+ begin
+ Fog::Errors.missing_credentials
+ rescue Fog::Errors::LoadError => error
+ abort error.message
+ end
end
require 'fog/bin'
View
4 lib/fog/core/errors.rb
@@ -16,6 +16,8 @@ class MockNotImplemented < Fog::Errors::Error; end
class NotFound < Fog::Errors::Error; end
+ class LoadError < LoadError; end
+
# @return [String] The error message that will be raised, if credentials cannot be found
def self.missing_credentials
missing_credentials_message = <<-YML
@@ -68,7 +70,7 @@ def self.missing_credentials
#######################################################
YML
- raise(LoadError.new(missing_credentials_message))
+ raise(Fog::Errors::LoadError.new(missing_credentials_message))
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.