Sha256: bc306fd02b01cffd82d2ba568407d8fcafd98a28be906f9bc739d7a405efd609

Contents?: true

Size: 898 Bytes

Versions: 4

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/gems_registry'

module Aranha
  module TemporaryErrorsManager
    GEMS_REGISTRY_MODULE_SUFFIX = 'TemporaryErrors'

    class << self
      enable_simple_cache

      # @return [Exception]
      def errors
        errors_providers.flat_map(&:errors)
      end

      # @return [Array]
      def errors_providers
        gems_registry.registered.map(&:registered_module)
      end

      # @param error Exception
      # @return [Boolean]
      def temporary_error?(error)
        return true if errors.any? { |klass| error.is_a?(klass) }

        error.cause.present? ? temporary_error?(error.cause) : false
      end

      private

      # @return [EacRubyUtils::GemsRegistry]
      def gems_registry_uncached
        ::EacRubyUtils::GemsRegistry.new(GEMS_REGISTRY_MODULE_SUFFIX)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aranha-0.19.2 lib/aranha/temporary_errors_manager.rb
aranha-0.19.1 lib/aranha/temporary_errors_manager.rb
aranha-0.19.0 lib/aranha/temporary_errors_manager.rb
aranha-0.18.0 lib/aranha/temporary_errors_manager.rb