Class: Utility::DocumentError

Inherits:
Object
  • Object
show all
Defined in:
lib/utility/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_class, error_message, stack_trace, error_id) ⇒ DocumentError

Returns a new instance of DocumentError.



14
15
16
17
18
19
20
21
22
# File 'lib/utility/errors.rb', line 14

def initialize(error_class, error_message, stack_trace, error_id)
  @error_class = error_class
  @error_message = error_message
  @error_id = error_id

  # keywords must be < 32kb, UTF-8 chars can be up to 3 bytes, thus 32k/3 ~= 10k
  # See https://github.com/elastic/workplace-search-team/issues/1723
  @stack_trace = stack_trace.truncate(10_000)
end

Instance Attribute Details

#error_classObject

Returns the value of attribute error_class.



12
13
14
# File 'lib/utility/errors.rb', line 12

def error_class
  @error_class
end

#error_idObject

Returns the value of attribute error_id.



12
13
14
# File 'lib/utility/errors.rb', line 12

def error_id
  @error_id
end

#error_messageObject

Returns the value of attribute error_message.



12
13
14
# File 'lib/utility/errors.rb', line 12

def error_message
  @error_message
end

#stack_traceObject

Returns the value of attribute stack_trace.



12
13
14
# File 'lib/utility/errors.rb', line 12

def stack_trace
  @stack_trace
end

Instance Method Details

#to_hObject



24
25
26
27
28
29
30
31
# File 'lib/utility/errors.rb', line 24

def to_h
  {
    'error_class' => error_class,
    'error_message' => error_message,
    'stack_trace' => stack_trace,
    'error_id' => error_id
  }
end