lib/telegram/bot/exceptions/response_error.rb in telegram-bot-ruby-1.0.0 vs lib/telegram/bot/exceptions/response_error.rb in telegram-bot-ruby-2.0.0

- old
+ new

@@ -4,24 +4,18 @@ module Bot module Exceptions class ResponseError < Base attr_reader :response - def initialize(response) + def initialize(response:) @response = response - super - end - def to_s - super + - format(' (%s)', data.map { |k, v| %(#{k}: "#{v}") }.join(', ')) + super "Telegram API has returned the error. (#{data.map { |k, v| %(#{k}: #{v.inspect}) }.join(', ')})" end def error_code data[:error_code] || data['error_code'] end - - private def data @data ||= begin JSON.parse(response.body) rescue JSON::ParserError