Module: Fog::CloudSigma::Errors

Defined in:
lib/fog/cloudsigma/error.rb

Defined Under Namespace

Classes: Error, NotFound, RequestError, ServerError

Class Method Summary collapse

Class Method Details

.slurp_http_status_error(error) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/cloudsigma/error.rb', line 18

def self.slurp_http_status_error(error)
  error_class =  case error.response[:status]
                   when 404
                     NotFound
                   when 500..599
                     ServerError
                   when 400..499
                     RequestError
                   else
                     Error
                 end

  new_error = error_class.new(error.response[:body].first['error_message'],
                              error.response[:body].first['error_type'],
                              error.response[:body].first['error_point'])
  new_error.set_backtrace(error.backtrace)
  new_error.verbose = error.message
  new_error
end