Sha256: c5344f200afa3ef5cd873b31502c697163ee87386a0193f397293f4c753927f1
Contents?: true
Size: 734 Bytes
Versions: 12
Compression:
Stored size: 734 Bytes
Contents
# frozen_string_literal: true module DubbletrackRemote class RateLimitError end class Error attr_accessor :time, :text, :code def initialize(response) @time = Time.now.iso8601 @code = response.status @text = error_text(response) end def error_text(response) error_text = response.body begin json = JSON.parse(response.body) errors = json["errors"] || [] error_text = errors.flatten.collect { |error| error["detail"] }.join(",") rescue JSON::ParserError # keep the error text as response.body end error_text end def to_json { text: @text, code: @code, time: @time } end end end
Version data entries
12 entries across 12 versions & 1 rubygems