1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Rackspace, openstack, hp API error messages are not set correctly in exceptions

This commit is contained in:
Carlos Sanchez 2012-12-05 19:53:11 +01:00
parent 6109001172
commit cff1ae8f70
3 changed files with 16 additions and 7 deletions

View file

@ -15,6 +15,9 @@ module Fog
else
data = Fog::JSON.decode(error.response.body)
message = data['message']
if message.nil? and !data.values.first.nil?
message = data.values.first['message']
end
end
new_error = super(error, message)
@ -33,8 +36,8 @@ module Fog
def self.slurp(error)
new_error = super(error)
unless new_error.response_data.nil?
new_error.instance_variable_set(:@validation_errors, new_error.response_data['validationErrors'])
unless new_error.response_data.nil? or new_error.response_data['badRequest'].nil?
new_error.instance_variable_set(:@validation_errors, new_error.response_data['badRequest']['validationErrors'])
end
new_error
end

View file

@ -15,6 +15,9 @@ module Fog
else
data = Fog::JSON.decode(error.response.body)
message = data['message']
if message.nil? and !data.values.first.nil?
message = data.values.first['message']
end
end
new_error = super(error, message)
@ -33,8 +36,8 @@ module Fog
def self.slurp(error)
new_error = super(error)
unless new_error.response_data.nil?
new_error.instance_variable_set(:@validation_errors, new_error.response_data['validationErrors'])
unless new_error.response_data.nil? or new_error.response_data['badRequest'].nil?
new_error.instance_variable_set(:@validation_errors, new_error.response_data['badRequest']['validationErrors'])
end
new_error
end

View file

@ -15,6 +15,9 @@ module Fog
else
data = Fog::JSON.decode(error.response.body)
message = data['message']
if message.nil? and !data.values.first.nil?
message = data.values.first['message']
end
end
new_error = super(error, message)
@ -29,13 +32,13 @@ module Fog
class ServiceUnavailable < ServiceError; end
class BadRequest < ServiceError
#TODO - Need to find a bette way to print out these validation errors when they are thrown
#TODO - Need to find a better way to print out these validation errors when they are thrown
attr_reader :validation_errors
def self.slurp(error)
new_error = super(error)
unless new_error.response_data.nil?
new_error.instance_variable_set(:@validation_errors, new_error.response_data['validationErrors'])
unless new_error.response_data.nil? or new_error.response_data['badRequest'].nil?
new_error.instance_variable_set(:@validation_errors, new_error.response_data['badRequest']['validationErrors'])
end
new_error
end