Sha256: b7d28cdd94bb5a39424619d469698b49152e4be991ce556a4eb2c723a4a8ee41
Contents?: true
Size: 1.91 KB
Versions: 2
Compression:
Stored size: 1.91 KB
Contents
# frozen_string_literal: true module Redd # Namespace for Redd errors. module Errors # An error raised by {Redd::Middleware} when there was an error returned by reddit. class TokenRetrievalError < StandardError; end # An error with the API. class APIError < StandardError attr_reader :response, :name def initialize(response) @response = response super(response.body[:json][:errors][0].join(', ')) end end # Indicates that you were rate limited. This should be taken care of automatically. class RateLimitError < APIError attr_reader :duration def initialize(response) super(response) @duration = response.body[:json][:ratelimit] end end # Represents an error from reddit returned in a response. class ResponseError < StandardError attr_accessor :response def initialize(response) super(response.raw_body.length <= 80 ? response.raw_body : "#{response.raw_body[0..80]}...") @response = response end end # An error returned by AuthStrategy. # @note A common cause of this error is not having a bot account registered as a developer on # the app. class AuthenticationError < ResponseError; end # An error with Redd, probably (let me know!) class BadRequest < ResponseError; end # Whatever it is, you're not allowed to do it. class Forbidden < ResponseError; end # You don't have the correct scope to do this. class InsufficientScope < ResponseError; end # The access object supplied was invalid. class InvalidAccess < ResponseError; end # Returned when reddit raises a 404 error. class NotFound < ResponseError; end # Too many requests and not enough rate limiting. class TooManyRequests < ResponseError; end # An unknown error on reddit's end. Usually fixed with a retry. class ServerError < ResponseError; end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
spinels-redd-0.9.0 | lib/redd/errors.rb |
redd-0.9.0.pre.3 | lib/redd/errors.rb |