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

Inherits:
BaseLoader
  • Object
show all
Defined in:
lib/eco/api/common/loaders/error_handler.rb

Direct Known Subclasses

Eco::API::Custom::ErrorHandler

Class Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseLoader

<=>, created_at, #name, name_only_once!, set_created_at!

Methods included from ClassHelpers

#class_resolver, #descendants, #descendants?, #new_class, #resolve_class, #to_constant

Constructor Details

#initialize(handlers) ⇒ ErrorHandler

Returns a new instance of ErrorHandler.



19
20
21
22
# File 'lib/eco/api/common/loaders/error_handler.rb', line 19

def initialize(handlers)
  raise "Expected Eco::API::Policies. Given #{handlers.class}" unless handlers.is_a?(Eco::API::Error::Handlers)
  handlers.on(self.error, &self.method(:main))
end

Class Attribute Details

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

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

Returns:



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

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

Instance Method Details

#errorObject



33
34
35
# File 'lib/eco/api/common/loaders/error_handler.rb', line 33

def error
  self.class.error
end

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

Parameters:

  • 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.



29
30
31
# File 'lib/eco/api/common/loaders/error_handler.rb', line 29

def main(people, session, options, handler, job)
  raise "You should implement this method"
end