Class: Statsig::ErrorBoundary

Inherits:
Object
  • Object
show all
Defined in:
lib/error_boundary.rb

Instance Method Summary collapse

Constructor Details

#initialize(sdk_key) ⇒ ErrorBoundary

Returns a new instance of ErrorBoundary.



7
8
9
10
# File 'lib/error_boundary.rb', line 7

def initialize(sdk_key)
  @sdk_key = sdk_key
  @seen = Set.new
end

Instance Method Details

#capture(task, recover = -> {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/error_boundary.rb', line 12

def capture(task, recover = -> {})
  begin
    return task.call
  rescue StandardError => e
    if e.is_a?(Statsig::UninitializedError) or e.is_a?(Statsig::ValueError)
      raise e
    end
    puts "[Statsig]: An unexpected exception occurred."
    log_exception(e)
    return recover.call
  end
end