123456789_123456789_123456789_123456789_123456789_

Exception: Mongo::Auth::InvalidMechanism

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Mongo::Auth::InvalidConfiguration
Defined in: lib/mongo/auth.rb

Overview

Raised when trying to get an invalid authorization mechanism.

Since:

  • 2.0.0

Class Method Summary

Instance Attribute Summary

::Mongo::Error::Notable - Included

#connection_global_id

Returns global id of the connection on which the error occurred.

#generation

Returns connection pool generation for the connection on which the error occurred.

#service_id

Returns service id for the connection on which the error occurred.

Instance Method Summary

::Mongo::Error::Notable - Included

#add_note,
#add_notes

Allows multiple notes to be added in a single call, for convenience.

#notes

Returns an array of strings with additional information about the exception.

#to_s, #notes_tail

Constructor Details

.new(_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

[ GitHub ]

  
# 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