Class: Chanko::ExceptionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/chanko/exception_handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception, unit = nil) ⇒ ExceptionHandler

Returns a new instance of ExceptionHandler.



9
10
11
12
# File 'lib/chanko/exception_handler.rb', line 9

def initialize(exception, unit = nil)
  @exception = exception
  @unit      = unit
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



7
8
9
# File 'lib/chanko/exception_handler.rb', line 7

def exception
  @exception
end

#unitObject (readonly)

Returns the value of attribute unit.



7
8
9
# File 'lib/chanko/exception_handler.rb', line 7

def unit
  @unit
end

Class Method Details

.handle(*args) ⇒ Object



3
4
5
# File 'lib/chanko/exception_handler.rb', line 3

def self.handle(*args)
  new(*args).handle
end

Instance Method Details

#handleObject



14
15
16
17
18
19
20
21
# File 'lib/chanko/exception_handler.rb', line 14

def handle
  if propagated?
    raise exception
  else
    log
    raise exception if raised?
  end
end