diff --git a/lib/fog/rackspace.rb b/lib/fog/rackspace.rb index 541e5ae49..15a8211bb 100644 --- a/lib/fog/rackspace.rb +++ b/lib/fog/rackspace.rb @@ -64,9 +64,12 @@ module Fog class ServiceUnavailable < ServiceError; end class MethodNotAllowed < ServiceError; end class BadRequest < ServiceError - #TODO - Need to find a better way to print out these validation errors when they are thrown attr_reader :validation_errors + def to_s + "#{super} - #{validation_errors}" + end + def self.slurp(error, service=nil) new_error = super(error) unless new_error.response_data.nil? or new_error.response_data['badRequest'].nil? diff --git a/lib/fog/rackspace/monitoring.rb b/lib/fog/rackspace/monitoring.rb index 33d22d030..0f1a762dc 100644 --- a/lib/fog/rackspace/monitoring.rb +++ b/lib/fog/rackspace/monitoring.rb @@ -13,10 +13,26 @@ module Fog class IdentifierTaken < Fog::Errors::Error; end class ServiceError < Fog::Rackspace::Errors::ServiceError; end class InternalServerError < Fog::Rackspace::Errors::InternalServerError; end - class BadRequest < Fog::Rackspace::Errors::BadRequest; end class Conflict < Fog::Rackspace::Errors::Conflict; end class ServiceUnavailable < Fog::Rackspace::Errors::ServiceUnavailable; end + + class BadRequest < Fog::Rackspace::Errors::BadRequest + attr_reader :validation_errors + + def self.slurp(error, service=nil) + new_error = super(error) + if new_error.response_data && new_error.response_data['details'] + new_error.instance_variable_set(:@validation_errors, new_error.response_data['details']) + end + + status_code = error.response ? error.response.status : nil + new_error.instance_variable_set(:@status_code, status_code) + new_error.set_transaction_id(error, service) + new_error + end + end + requires :rackspace_api_key, :rackspace_username recognizes :rackspace_auth_url recognizes :persistent