Sha256: f62383c3d6937b6f1468fc52f5ab3ed201c95c0968f9e1df31a2cdeec7d47292

Contents?: true

Size: 981 Bytes

Versions: 162

Compression:

Stored size: 981 Bytes

Contents

module Eco
  module API
    class Error
      class Handlers < Eco::API::UseCases
        autoloads_children_of "Eco::API::Common::Loaders::ErrorHandler"
        autoload_namespace_ignore "Eco::API"

        def define(*args)
          raise "Missusage. You should use 'on' method instead"
        end

        # @param klass_err [Eco::API::Error] the specific error class that triggers this handler.
        def on(klass_err, type: :error_handler, retry: true, &block)
          Eco::API::Error.validate_err_class(klass_err)
          raise "Expected block but not given" unless block
          Eco::API::Error::Handler.new(klass_err, type: type, root: self, &block).tap do |handler|
            add(handler)
          end
        end

        def add(handler)
          raise "Expected Eco::API::Error::Handler object. Given: #{policy}" unless handler.is_a?(Eco::API::Error::Handler)
          super(handler)
        end

      end
    end
  end
end

Version data entries

162 entries across 162 versions & 1 rubygems

Version Path
eco-helpers-1.5.3 lib/eco/api/error/handlers.rb
eco-helpers-1.5.2 lib/eco/api/error/handlers.rb