mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace|monitoring] updating BadRequest exceptions to include validation errors
This commit is contained in:
parent
2c4497cd88
commit
dfc72835df
2 changed files with 21 additions and 2 deletions
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue