123456789_123456789_123456789_123456789_123456789_

Module: Mongo::Error::Notable Private

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
::Mongo::Auth::Aws::CredentialsNotFound, ::Mongo::Auth::InvalidConfiguration, ::Mongo::Auth::InvalidMechanism, ::Mongo::Auth::Unauthorized, ::Mongo::Error, AuthError, BadLoadBalancerTarget, BulkWriteError, ClientClosed, ClosedStream, ConnectionPerished, ConnectionUnavailable, CredentialCheckError, CryptError, ExtraFileChunk, FailedStringPrepValidation, FileNotFound, HandshakeError, InsufficientIterationCount, InternalDriverError, InvalidAddress, InvalidApplicationName, InvalidBulkOperation, InvalidBulkOperationType, InvalidCollectionName, InvalidConfigOption, InvalidCursorOperation, InvalidDatabaseName, InvalidDocument, InvalidFile, InvalidFileRevision, InvalidMaxConnecting, InvalidMinPoolSize, InvalidNonce, InvalidReadConcern, InvalidReadOption, InvalidReplacementDocument, InvalidServerAuthHost, InvalidServerAuthResponse, InvalidServerPreference, InvalidSession, InvalidSignature, InvalidTXTRecord, InvalidTransactionOperation, InvalidURI, InvalidUpdateDocument, InvalidWriteConcern, KmsError, LintError, MaxBSONSize, MaxMessageSize, MismatchedDomain, MissingConnection, MissingFileChunk, MissingPassword, MissingResumeToken, MissingScramServerSignature, MissingServiceId, MongocryptdSpawnError, MultiIndexDrop, NeedPrimaryServer, NoSRVRecords, NoServerAvailable, NoServiceConnectionAvailable, OperationFailure, PoolClearedError, PoolClosedError, PoolError, PoolPausedError, ServerApiConflict, ServerCertificateRevoked, ServerNotUsable, ServerTimeoutError, SessionEnded, SessionNotMaterialized, SessionsNotSupported, SnapshotSessionInvalidServerVersion, SnapshotSessionTransactionProhibited, SocketError, SocketTimeoutError, TimeoutError, TransactionsNotSupported, UnchangeableCollectionOption, UnexpectedChunkLength, UnexpectedResponse, UnknownPayloadType, UnmetDependency, UnsupportedArrayFilters, UnsupportedCollation, UnsupportedFeatures, UnsupportedMessageType, UnsupportedOption, ::Mongo::Server::AppMetadata::Environment::MissingVariable, ::Mongo::Server::AppMetadata::Environment::TooManyEnvironments, ::Mongo::Server::AppMetadata::Environment::TypeMismatch, ::Mongo::Server::AppMetadata::Environment::ValueTooLong
Defined in: lib/mongo/error/notable.rb

Overview

A module encapsulating functionality to manage data attached to exceptions in the driver, since the driver does not currently have a single exception hierarchy root.

Since:

  • 2.11.0

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#connection_global_idInteger | nil (rw)

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

Returns:

  • (Integer | nil)

    Connection global id.

Since:

  • 2.11.0

[ GitHub ]

  
# File 'lib/mongo/error/notable.rb', line 79

attr_accessor :connection_global_id

#generationInteger | nil (rw)

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

Returns:

  • (Integer | nil)

    Connection pool generation.

Since:

  • 2.11.0

[ GitHub ]

  
# File 'lib/mongo/error/notable.rb', line 65

attr_accessor :generation

#service_idObject | nil (rw)

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

Returns:

  • (Object | nil)

    Service id.

Since:

  • 2.11.0

[ GitHub ]

  
# File 'lib/mongo/error/notable.rb', line 72

attr_accessor :service_id

Instance Method Details

#add_note(note)

Since:

  • 2.11.0

[ GitHub ]

  
# File 'lib/mongo/error/notable.rb', line 42

def add_note(note)
  @notes ||= []
  if Lint.enabled? && @notes.include?(note)
    # The driver makes an effort to not add duplicated notes, by
    # keeping track of *when* a particular exception should have the
    # particular notes attached to it throughout the call stack.
    raise Error::LintError, "Adding a note which already exists in exception #{self}: #{note}"
  end

  @notes << note
end

#add_notes(*notes)

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

Since:

  • 2.11.0

[ GitHub ]

  
# File 'lib/mongo/error/notable.rb', line 57

def add_notes(*notes)
  notes.each { |note| add_note(note) }
end

#notesArray<String>

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

Returns:

  • (Array<String>)

    Additional information strings.

Since:

  • 2.11.0

[ GitHub ]

  
# File 'lib/mongo/error/notable.rb', line 33

def notes
  if @notes
    @notes.dup
  else
    []
  end
end

#notes_tail (private)

Since:

  • 2.11.0

[ GitHub ]

  
# File 'lib/mongo/error/notable.rb', line 89

def notes_tail
  msg = ''
  msg += " (#{notes.join(', ')})" unless notes.empty?
  msg
end

#to_s

Since:

  • 2.11.0

[ GitHub ]

  
# File 'lib/mongo/error/notable.rb', line 82

def to_s
  super + notes_tail
end