Exception: Mongo::Auth::InvalidMechanism

Inherits:
InvalidConfiguration show all
Defined in:
lib/mongo/auth.rb

Overview

Raised when trying to get an invalid authorization mechanism.

Since:

  • 2.0.0

Instance Attribute Summary

Attributes included from Error::Notable

#connection_global_id, #generation, #service_id

Instance Method Summary collapse

Methods included from Error::Notable

#add_note, #add_notes, #notes, #to_s

Constructor Details

#initialize(_mechanism = nil) ⇒ InvalidMechanism

Instantiate the new error.

The mechanism is not included in the message: an unrecognized value comes from the connection string and may contain text the user intended as a credential. The known mechanisms are listed so the message stays actionable.

Examples:

Instantiate the error.

Mongo::Auth::InvalidMechanism.new(:test)

Parameters:

  • _mechanism (Symbol | String | nil) (defaults to: nil) —

    The provided mechanism.

Since:

  • 2.0.0



123
124
125
126
127
128
# File 'lib/mongo/auth.rb', line 123

def initialize(_mechanism = nil)
  known_mechanisms = SOURCES.keys.sort.map do |key|
    key.inspect
  end.join(', ')
  super("Invalid authentication mechanism, please use one of the following mechanisms: #{known_mechanisms}")
end