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-2.1.2 lib/eco/api/error/handlers.rb
eco-helpers-2.1.1 lib/eco/api/error/handlers.rb
eco-helpers-2.0.68 lib/eco/api/error/handlers.rb
eco-helpers-2.0.67 lib/eco/api/error/handlers.rb
eco-helpers-2.0.66 lib/eco/api/error/handlers.rb
eco-helpers-2.0.65 lib/eco/api/error/handlers.rb
eco-helpers-2.0.64 lib/eco/api/error/handlers.rb
eco-helpers-2.0.63 lib/eco/api/error/handlers.rb
eco-helpers-2.0.62 lib/eco/api/error/handlers.rb
eco-helpers-2.0.61 lib/eco/api/error/handlers.rb
eco-helpers-2.0.60 lib/eco/api/error/handlers.rb
eco-helpers-2.0.59 lib/eco/api/error/handlers.rb
eco-helpers-2.0.58 lib/eco/api/error/handlers.rb
eco-helpers-2.0.57 lib/eco/api/error/handlers.rb
eco-helpers-2.0.56 lib/eco/api/error/handlers.rb
eco-helpers-2.0.55 lib/eco/api/error/handlers.rb
eco-helpers-2.0.54 lib/eco/api/error/handlers.rb
eco-helpers-2.0.53 lib/eco/api/error/handlers.rb
eco-helpers-2.0.52 lib/eco/api/error/handlers.rb
eco-helpers-2.0.51 lib/eco/api/error/handlers.rb