Class: Findbug::Capture::ExceptionHandler
- Inherits:
-
Object
- Object
- Findbug::Capture::ExceptionHandler
- Defined in:
- lib/findbug/capture/exception_handler.rb
Overview
ExceptionHandler provides the public API for capturing exceptions.
This is used by:
-
Findbug.capture_exception (public API)
-
Manual captures in user code
It’s separate from Middleware/Subscriber because those are automatic. This is for explicit, manual captures.
WHEN TO USE MANUAL CAPTURE
-
Handled exceptions you still want to track:
begin
external_api.callrescue ExternalAPIError => e
Findbug.capture_exception(e) # Handle gracefully...end
-
Exceptions in background jobs (if not auto-captured):
class HardWorker
def perform do_work rescue => e Findbug.capture_exception(e) raise # Re-raise for Sidekiq retry endend
-
Exceptions with extra context:
Findbug.capture_exception(e, order_id: order.id, action: “payment”)
Class Method Summary collapse
-
.capture(exception, extra_context = {}) ⇒ Object
Capture an exception.
Class Method Details
.capture(exception, extra_context = {}) ⇒ Object
Capture an exception
51 52 53 54 55 56 57 58 59 |
# File 'lib/findbug/capture/exception_handler.rb', line 51 def capture(exception, extra_context = {}) return unless Findbug.enabled? return unless should_capture?(exception) event_data = build_event_data(exception, extra_context) Storage::RedisBuffer.push_error(event_data) rescue StandardError => e Findbug.logger.error("[Findbug] ExceptionHandler failed: #{e.}") end |