Module: Switchman::StandardError
- Defined in:
- lib/switchman/standard_error.rb
Instance Method Summary collapse
Instance Method Details
#current_shard(klass = ::ActiveRecord::Base) ⇒ Object
25 26 27 |
# File 'lib/switchman/standard_error.rb', line 25 def current_shard(klass = ::ActiveRecord::Base) @active_shards&.[](klass) || Shard.default end |
#initialize(*args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/switchman/standard_error.rb', line 5 def initialize(*args) super # These seem to get themselves into a bad state if we try to lookup shards while processing return if is_a?(IO::EAGAINWaitReadable) return if Thread.current[:switchman_error_handler] begin Thread.current[:switchman_error_handler] = true @active_shards ||= Shard.active_shards rescue # intentionally empty - don't allow calculating the active_shards to prevent # creating the StandardError for any reason. this prevents various random issues # when a StandardError is created within a finalizer ensure Thread.current[:switchman_error_handler] = nil end end |