Method: NaranyaEcm::Rest::RestError.build_from_failed_response

Defined in:
lib/naranya_ecm/rest/errors.rb

.build_from_failed_response(response, message = "") ⇒ Object

Captura un response y genera una excepción.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/naranya_ecm/rest/errors.rb', line 44

def self.build_from_failed_response(response, message = "")
  klass = case response.status
  when 401 then AuthorizationRequired
  when 403 then Forbidden
  when 404 then ResourceNotFound
  when 422 then UnprocessableEntity
  else RemoteFailed
  end

  klass.new response
end