Exception: Rubyists::Leopard::LeopardError

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

Overview

Base Leopard exception that truncates backtraces for cleaner logs.

Direct Known Subclasses

Error

Instance Method Summary collapse

Constructor Details

#initializevoid

Captures the original exception state while replacing the backtrace with the current call stack.



10
11
12
13
# File 'lib/leopard/errors.rb', line 10

def initialize(...)
  super
  set_backtrace(caller)
end

Instance Method Details

#backtraceArray<String>

Returns a Leopard-truncated backtrace.

Returns:

  • (Array<String>)

    Up to the first four backtrace entries, plus a truncation marker when applicable.



18
19
20
21
22
23
24
25
26
# File 'lib/leopard/errors.rb', line 18

def backtrace
  # If the backtrace is nil, return an empty array
  orig = (super || [])[0..3]
  # If the backtrace is less than 4 lines, return it as is
  return orig if orig.size < 4

  # Otherwise, add a note indicating truncation
  orig + ['... (truncated by Leopard)']
end