Sha256: 03fadf07733e66dbf42e5b97b3edeb39121ba92720d782ff2b9bd8c7ebfa431c

Contents?: true

Size: 652 Bytes

Versions: 26

Compression:

Stored size: 652 Bytes

Contents

module Eco
  module API
    class Error
      class Handlers < Eco::API::UseCases

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

        def on(klass_err, type: :transform, 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

      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
eco-helpers-1.2.2 lib/eco/api/error/handlers.rb
eco-helpers-1.2.1 lib/eco/api/error/handlers.rb
eco-helpers-1.1.8 lib/eco/api/error/handlers.rb
eco-helpers-1.1.7 lib/eco/api/error/handlers.rb
eco-helpers-1.1.6 lib/eco/api/error/handlers.rb
eco-helpers-1.1.5 lib/eco/api/error/handlers.rb
eco-helpers-1.1.4 lib/eco/api/error/handlers.rb
eco-helpers-1.1.3 lib/eco/api/error/handlers.rb
eco-helpers-1.1.2 lib/eco/api/error/handlers.rb
eco-helpers-1.1.1 lib/eco/api/error/handlers.rb
eco-helpers-1.0.14 lib/eco/api/error/handlers.rb
eco-helpers-1.0.13 lib/eco/api/error/handlers.rb
eco-helpers-1.0.12 lib/eco/api/error/handlers.rb
eco-helpers-1.0.11 lib/eco/api/error/handlers.rb
eco-helpers-1.0.10 lib/eco/api/error/handlers.rb
eco-helpers-1.0.9 lib/eco/api/error/handlers.rb
eco-helpers-1.0.8 lib/eco/api/error/handlers.rb
eco-helpers-1.0.7 lib/eco/api/error/handlers.rb
eco-helpers-1.0.6 lib/eco/api/error/handlers.rb
eco-helpers-1.0.5 lib/eco/api/error/handlers.rb