Class: Eco::API::Error::Handlers
- Defined in:
- lib/eco/api/error/handlers.rb
Instance Method Summary collapse
- #add(handler) ⇒ Object
- #define(*args) ⇒ Object
- #on(klass_err, type: :error_handler, retry: true, &block) ⇒ Object
Methods inherited from UseCases
#case, #defined?, #dup, #each, #empty?, #initialize, #items, #length, #merge, #name?, #names, #types
Methods included from Common::ClassAutoLoader
#_autoload_namespace, #autoload_children, #autoload_class?, #autoload_namespace, #autoload_namespace_ignore, #autoloaded_children, #autoloaded_class, #autoloaded_namespaces, #autoloads_children_of, #known_class!, #known_classes, #new_classes, #unloaded_children
Methods included from Common::ClassHelpers
#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant
Constructor Details
This class inherits a constructor from Eco::API::UseCases
Instance Method Details
#add(handler) ⇒ Object
21 22 23 24 |
# File 'lib/eco/api/error/handlers.rb', line 21 def add(handler) raise "Expected Eco::API::Error::Handler object. Given: #{policy}" unless handler.is_a?(Eco::API::Error::Handler) super(handler) end |
#define(*args) ⇒ Object
8 9 10 |
# File 'lib/eco/api/error/handlers.rb', line 8 def define(*args) raise "Missusage. You should use 'on' method instead" end |
#on(klass_err, type: :error_handler, retry: true, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/eco/api/error/handlers.rb', line 13 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 |