Method: Mongo::Server#handle_auth_failure!

Defined in:
lib/mongo/server.rb

#handle_auth_failure!Object

Handle authentication failure.

Examples:

Handle possible authentication failure.

server.handle_auth_failure! do
  Auth.get(user).(self)
end

Returns:

  • (Object)

    The result of the block execution.

Raises:

Since:

  • 2.3.0



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# File 'lib/mongo/server.rb', line 529

def handle_auth_failure!
  yield
rescue Mongo::Error::SocketTimeoutError
  # possibly cluster is slow, do not give up on it
  raise
rescue Mongo::Error::SocketError, Auth::Unauthorized => e
  # non-timeout network error or auth error, clear the pool and mark the
  # topology as unknown
  unknown!(
    generation: e.generation,
    service_id: e.service_id,
    stop_push_monitor: true,
  )
  raise
end