Class: Eco::API::Common::Loaders::ErrorHandler

Inherits:
CaseBase show all
Defined in:
lib/eco/api/common/loaders/error_handler.rb

Direct Known Subclasses

Eco::API::Custom::ErrorHandler

Class Attribute Summary collapse

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods inherited from CaseBase

#name, name_only_once!, original_name

Methods inherited from Base

<=>, created_at, set_created_at!

Methods included from Language::Klass::InheritableClassVars

#inheritable_attrs, #inheritable_class_vars, #inherited

Methods included from Language::Klass::Naming

#instance_variable_name, #to_constant

Methods included from Language::Klass::Hierarchy

#descendants, #descendants?

Methods included from Language::Klass::Builder

#new_class

Methods included from Language::Klass::Uid

#uid

Methods included from Language::Klass::Resolver

#class_resolver, #resolve_class

Methods included from Language::Klass::Const

#if_const, #redef_without_warning

Methods included from Language::AuxiliarLogger

#log

Constructor Details

#initialize(handlers) ⇒ ErrorHandler

Instance Methods



23
24
25
26
27
28
# File 'lib/eco/api/common/loaders/error_handler.rb', line 23

def initialize(handlers) # rubocop:disable Lint/MissingSuper

  msg = "Expected Eco::API::Policies. Given #{handlers.class}"
  raise msg unless handlers.is_a?(Eco::API::Error::Handlers)

  handlers.on(error, &method(:main))
end

Class Attribute Details

.error(value = nil) ⇒ Eco::API::Error

Returns the error class, child of Eco::API::Error.

Returns:



10
11
12
13
14
15
16
# File 'lib/eco/api/common/loaders/error_handler.rb', line 10

def error(value = nil)
  unless value
    msg = "You should specify an error type for #{self.class}"
    return @error || (raise msg)
  end
  @error = value
end

Instance Method Details

#errorObject



40
41
42
# File 'lib/eco/api/common/loaders/error_handler.rb', line 40

def error
  self.class.error
end

#main(data, session, options, handler, job) ⇒ Object

Parameters:

  • data (Variant)
    • people [Eco::API::Organization::People] the people in the queue of the current job
  • session (Eco::API::Session)

    the current session where the usecase kicks in.

  • options (Hash)

    the options that modify the case behaviour or bring some dependencies.

  • handler (Eco::API::Error::Hanlder)

    the error handler instance object.

  • job (Eco::API::Session::Batch::Job)

    the Batch::Job made on purpose for this handler.



36
37
38
# File 'lib/eco/api/common/loaders/error_handler.rb', line 36

def main(data, session, options, handler, job) # rubocop:disable Lint/UnusedMethodArgument

  raise 'You should implement this method'
end