Skip to Content Skip to Search

Shareable stand-in for a main-side exception

Methods
E
N
R

Class Public methods

new(error)

# File activerecord/lib/active_record/connection_adapters/ractor_connection_handler/proxy.rb, line 23
def initialize(error)
  @error_class = error.class
  @message = error.message.to_s
  @backtrace = error.backtrace
  @cause = ErrorResponse.new(error.cause) if error.cause
  @ivars = capture_ivars(error) if reconstructible?(error)
  ActiveSupport::Ractors.make_shareable(self, copy: false)
end

Instance Public methods

exception(connection_pool: nil)

# File activerecord/lib/active_record/connection_adapters/ractor_connection_handler/proxy.rb, line 32
def exception(connection_pool: nil)
  remote = remote_error
  error =
    if @ivars
      rebuilt = @error_class.allocate.exception(@message)
      @ivars.each { |name, value| rebuilt.instance_variable_set(name, value) }
      rebuilt.instance_variable_set(:@connection_pool, connection_pool) if rebuilt.is_a?(AdapterError)
      attach_cause(rebuilt, remote)
    else
      remote
    end
  error.set_backtrace(@backtrace + caller) if @backtrace
  error
end

remote_error()

# File activerecord/lib/active_record/connection_adapters/ractor_connection_handler/proxy.rb, line 47
def remote_error
  error = RemoteError.new(@error_class, @message)
  error.set_backtrace(@backtrace) if @backtrace
  @cause ? attach_cause(error, @cause.remote_error) : error
end