Exception: Rubyists::Leopard::LeopardError
- Inherits:
-
StandardError
- Object
- StandardError
- Rubyists::Leopard::LeopardError
- Defined in:
- lib/leopard/errors.rb
Overview
Base Leopard exception that truncates backtraces for cleaner logs.
Direct Known Subclasses
Instance Method Summary collapse
-
#backtrace ⇒ Array<String>
Returns a Leopard-truncated backtrace.
-
#initialize ⇒ void
constructor
Captures the original exception state while replacing the backtrace with the current call stack.
Constructor Details
#initialize ⇒ void
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
#backtrace ⇒ Array<String>
Returns a Leopard-truncated backtrace.
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 |