Module: XlsFunction::Evaluators::ErrorDetector

Included in:
FunctionEvaluator
Defined in:
lib/xls_function/evaluators/error_detector.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
7
8
# File 'lib/xls_function/evaluators/error_detector.rb', line 4

def self.included(klass)
  klass.class_eval do
    attr_reader :error_value
  end
end

Instance Method Details

#class_info(message = '') ⇒ Object



20
21
22
# File 'lib/xls_function/evaluators/error_detector.rb', line 20

def class_info(message = '')
  "#{class_name.upcase}:#{message}"
end

#class_nameObject



24
25
26
# File 'lib/xls_function/evaluators/error_detector.rb', line 24

def class_name
  self.class.name&.split('::')&.last || 'Class'
end

#rescue_with(error_class) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/xls_function/evaluators/error_detector.rb', line 10

def rescue_with(error_class)
  yield
rescue error_class => e
  if XlsFunction.verbose
    XlsFunction.logger.write(e.inspect)
    XlsFunction.logger.write(e.backtrace)
  end
  ::XlsFunction::ErrorValue.value!(class_info(e.message))
end