Renamed the error vars

This commit is contained in:
Tim Emiola 2015-02-17 18:43:00 -08:00
parent a5bb601fe3
commit 7adcf42958
2 changed files with 6 additions and 6 deletions

View File

@ -34,7 +34,7 @@ module Google
# Module Auth provides classes that provide Google-specific authorization
# used to access Google APIs.
module Auth
NOT_FOUND = <<END
NOT_FOUND_ERROR = <<END
Could not load the default credentials. Browse to
https://developers.google.com/accounts/docs/application-default-credentials
for more information
@ -53,7 +53,7 @@ END
return creds unless creds.nil?
creds = ServiceAccountCredentials.from_well_known_path(scope)
return creds unless creds.nil?
fail NOT_FOUND unless GCECredentials.on_gce?(options)
fail NOT_FOUND_ERROR unless GCECredentials.on_gce?(options)
GCECredentials.new
end

View File

@ -54,11 +54,11 @@ module Google
# cf [Application Default Credentials](http://goo.gl/mkAHpZ)
class ServiceAccountCredentials < Signet::OAuth2::Client
ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS'
NOT_FOUND_PREFIX =
NOT_FOUND_ERROR =
"Unable to read the credential file specified by #{ENV_VAR}"
TOKEN_CRED_URI = 'https://www.googleapis.com/oauth2/v3/token'
WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json'
WELL_KNOWN_PREFIX = 'Unable to read the default credential file'
WELL_KNOWN_ERROR = 'Unable to read the default credential file'
class << self
extend Memoist
@ -79,7 +79,7 @@ module Google
fail 'file #{path} does not exist' unless File.exist?(path)
return new(scope, File.open(path))
rescue StandardError => e
raise "#{NOT_FOUND_PREFIX}: #{e}"
raise "#{NOT_FOUND_ERROR}: #{e}"
end
# Creates an instance from a well known path.
@ -94,7 +94,7 @@ module Google
return nil unless File.exist?(path)
return new(scope, File.open(path))
rescue StandardError => e
raise "#{WELL_KNOWN_PREFIX}: #{e}"
raise "#{WELL_KNOWN_ERROR}: #{e}"
end
end