Sha256: 3a3abab2b032607a9e8a0792a7c9a0cef003fb552b5221dc31eab14479fe54f3
Contents?: true
Size: 708 Bytes
Versions: 11
Compression:
Stored size: 708 Bytes
Contents
# frozen_string_literal: true module Telegram module Bot module Exceptions class ResponseError < Base attr_reader :response def initialize(response) @response = response super end def to_s super + format(' (%s)', data.map { |k, v| %(#{k}: "#{v}") }.join(', ')) end def error_code data[:error_code] || data['error_code'] end private def data @data ||= begin JSON.parse(response.body) rescue JSON::ParserError { error_code: response.status, uri: response.env.url.to_s } end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems