Sha256: 7db5aebd930ce74a9a8df3cb721ec3c5433f4ee5ac3c00c1b6e8edc1a862bef2

Contents?: true

Size: 582 Bytes

Versions: 16

Compression:

Stored size: 582 Bytes

Contents

module Telegram
  module Bot
    module Exceptions
      class ResponseError < Base
        attr_reader :response

        def initialize(response)
          @response = response
        end

        def to_s
          super +
            format(' (%s)', data.map { |k, v| %(#{k}: "#{v}") }.join(', '))
        end

        private

        def data
          @data ||= begin
            JSON.parse(response.body)
          rescue JSON::ParserError
            { error_code: response.code, uri: response.request.last_uri.to_s }
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
telegram-bot-ruby-0.3.10 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.9 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.8 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.7 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.6 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.5 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.4 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.3 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.2 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.1 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.3.0 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.2.6 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.2.5 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.2.4 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.2.3 lib/telegram/bot/exceptions/response_error.rb
telegram-bot-ruby-0.2.2 lib/telegram/bot/exceptions/response_error.rb