lib/redd/api_client.rb in redd-0.8.8 vs lib/redd/api_client.rb in redd-0.9.0.pre.1

- old
+ new

@@ -1,9 +1,8 @@ # frozen_string_literal: true require_relative 'client' -require_relative 'error' require_relative 'utilities/error_handler' require_relative 'utilities/rate_limiter' require_relative 'utilities/unmarshaller' module Redd @@ -85,15 +84,15 @@ # Makes sure a valid access is present, raising an error if nil def ensure_access_is_valid # If access is nil, panic raise 'client access is nil, try calling #authenticate' if @access.nil? # Refresh access if auto_refresh is enabled - refresh if @auto_refresh && @access.permanent? && @access.expired? + refresh if @access.expired? && @auto_refresh && @auth && @auth.refreshable?(@access) end def handle_retryable_errors response = yield - rescue Redd::ServerError, HTTP::TimeoutError => e + rescue Errors::ServerError, HTTP::TimeoutError => e # FIXME: maybe only retry GET requests, for obvious reasons? @failures += 1 raise e if @failures > @max_retries warn "Redd got a #{e.class.name} error (#{e.message}), retrying..." retry