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-1.4.1 lib/freddy/error_response.rb
freddy-1.4.0 lib/freddy/error_response.rb
freddy-1.3.3 lib/freddy/error_response.rb
freddy-jruby-1.3.2 lib/freddy/error_response.rb
freddy-1.3.2 lib/freddy/error_response.rb
freddy-1.3.1 lib/freddy/error_response.rb
freddy-1.3.0 lib/freddy/error_response.rb
freddy-1.2.0 lib/freddy/error_response.rb
freddy-1.1.0 lib/freddy/error_response.rb
freddy-1.0.1 lib/freddy/error_response.rb
freddy-jruby-1.0.0 lib/freddy/error_response.rb
freddy-1.0.0 lib/freddy/error_response.rb
freddy-jruby-0.7.2 lib/freddy/error_response.rb
freddy-0.7.2 lib/freddy/error_response.rb
freddy-0.7.1 lib/freddy/error_response.rb
freddy-0.7.0 lib/freddy/error_response.rb
freddy-0.6.3 lib/freddy/error_response.rb
freddy-0.6.2 lib/freddy/error_response.rb
freddy-0.6.1 lib/freddy/error_response.rb
freddy-jruby-0.6.0 lib/freddy/error_response.rb