Class: Statsig::ErrorBoundary
- Inherits:
-
Object
- Object
- Statsig::ErrorBoundary
- Defined in:
- lib/error_boundary.rb
Instance Method Summary collapse
- #capture(task:, recover: -> {}, caller: nil) ⇒ Object
-
#initialize(sdk_key) ⇒ ErrorBoundary
constructor
A new instance of ErrorBoundary.
Constructor Details
#initialize(sdk_key) ⇒ ErrorBoundary
Returns a new instance of ErrorBoundary.
8 9 10 11 |
# File 'lib/error_boundary.rb', line 8 def initialize(sdk_key) @sdk_key = sdk_key @seen = Set.new end |
Instance Method Details
#capture(task:, recover: -> {}, caller: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/error_boundary.rb', line 13 def capture(task:, recover: -> {}, caller: nil) begin res = task.call rescue StandardError, SystemStackError => e if e.is_a?(Statsig::UninitializedError) || e.is_a?(Statsig::ValueError) raise e end puts '[Statsig]: An unexpected exception occurred.' puts e. log_exception(e, tag: caller) res = recover.call end return res end |