Sha256: 07ff0a1560f9b161b321bed8749cd70694c4d5731b33d6d14e9d2caf69d1b268
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
module Duracloud class ErrorHandler def self.call(response) new(response).call end attr_reader :response def initialize(response) @response = response # XXX dup? end def call message = response_has_error_message? ? response.body : status_message raise handle_status, message end def status_message [response.status, response.reason].join(' ') end def server_error? response.status >= 500 end def handle_status send("handle_#{response.status}") rescue NoMethodError server_error? ? handle_server_error : handle_default end def handle_server_error ServerError end def handle_default Error end def handle_404 NotFoundError end def response_has_error_message? response.plain_text? && response.has_body? end end # class StoreContentErrorHandler < ErrorHandler # def handle_400 # InvalidContentIDError # end # def handle_409 # ChecksumError # end # end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
duracloud-client-0.0.1 | lib/duracloud/error_handler.rb |