Class: Julewire::Core::Serialization::ExceptionShape

Inherits:
Object
  • Object
show all
Defined in:
lib/julewire/core/serialization/exception_shape.rb

Constant Summary collapse

DEFAULT_MAX_CAUSE_DEPTH =
5

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_backtrace_lines:, max_cause_depth:) ⇒ ExceptionShape

Returns a new instance of ExceptionShape.



20
21
22
23
24
# File 'lib/julewire/core/serialization/exception_shape.rb', line 20

def initialize(max_backtrace_lines:, max_cause_depth:)
  @backtrace_limiter = BacktraceLimiter.new(max_backtrace_lines: max_backtrace_lines)
  @include_backtraces = max_backtrace_lines.positive?
  @max_cause_depth = Validation.validate_integer_limit!(max_cause_depth, name: :max_cause_depth)
end

Class Method Details

.call(error, max_backtrace_lines: Core::MAX_BACKTRACE_LINES, max_cause_depth: DEFAULT_MAX_CAUSE_DEPTH) ⇒ Object



12
13
14
15
16
17
# File 'lib/julewire/core/serialization/exception_shape.rb', line 12

def call(error, max_backtrace_lines: Core::MAX_BACKTRACE_LINES, max_cause_depth: DEFAULT_MAX_CAUSE_DEPTH)
  new(
    max_backtrace_lines: max_backtrace_lines,
    max_cause_depth: max_cause_depth
  ).call(error)
end

Instance Method Details

#call(error) ⇒ Object



26
27
28
# File 'lib/julewire/core/serialization/exception_shape.rb', line 26

def call(error)
  traverse(error) { |root, depth| shape_exception(root, depth) }
end