Class: Telebugs::WrappedError

Inherits:
Object
  • Object
show all
Defined in:
lib/telebugs/wrapped_error.rb

Overview

WrappedError unwraps an error and its causes up to a certain depth.

Constant Summary collapse

MAX_NESTED_ERRORS =
3

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ WrappedError

Returns a new instance of WrappedError.



8
9
10
# File 'lib/telebugs/wrapped_error.rb', line 8

def initialize(error)
  @error = error
end

Instance Method Details

#unwrapObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/telebugs/wrapped_error.rb', line 12

def unwrap
  error_list = []
  error = @error

  while error && error_list.size < MAX_NESTED_ERRORS
    error_list << error
    error = error.cause
  end

  error_list
end