Sha256: 7b212eccd535a09c394ec27c782f95fba80228bafa866cb825fb4cda922e8eb9

Contents?: true

Size: 494 Bytes

Versions: 37

Compression:

Stored size: 494 Bytes

Contents

class Freddy
  class ErrorResponse < StandardError
    DEFAULT_ERROR_MESSAGE = 'Use #response to get the error response'

    attr_reader :response

    def initialize(response)
      @response = response
      super(format_message(response) || DEFAULT_ERROR_MESSAGE)
    end

    private

    def format_message(response)
      return unless response.is_a?(Hash)

      message = [response[:error], response[:message]].compact.join(': ')
      message.empty? ? nil : message
    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
freddy-0.6.0 lib/freddy/error_response.rb
freddy-0.5.8 lib/freddy/error_response.rb
freddy-0.5.7 lib/freddy/error_response.rb
freddy-jruby-0.5.6 lib/freddy/error_response.rb
freddy-0.5.6 lib/freddy/error_response.rb
freddy-0.5.5 lib/freddy/error_response.rb
freddy-0.5.3 lib/freddy/error_response.rb
freddy-0.5.2 lib/freddy/error_response.rb
freddy-jruby-0.5.1 lib/freddy/error_response.rb
freddy-0.5.1 lib/freddy/error_response.rb
freddy-jruby-0.5.0 lib/freddy/error_response.rb
freddy-0.5.0 lib/freddy/error_response.rb
freddy-jruby-0.4.9 lib/freddy/error_response.rb
freddy-0.4.9 lib/freddy/error_response.rb
freddy-0.4.8 lib/freddy/error_response.rb
freddy-0.4.7 lib/freddy/error_response.rb
freddy-0.4.6 lib/freddy/error_response.rb