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, ServerApiNotSupported, ServerCertificateRevoked, ServerNotUsable, SessionEnded, SessionNotMaterialized, SessionsNotSupported, SnapshotSessionInvalidServerVersion, SnapshotSessionTransactionProhibited, SocketError, SocketTimeoutError, 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 85

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 71

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 78

attr_accessor :service_id

Instance Method Details

#add_note(note)

Since:

  • 2.11.0

[ GitHub ]

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

def add_note(note)
  unless @notes
    @notes = []
  end
  if Lint.enabled?
    if @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
  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 63

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 36

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

#notes_tail (private)

Since:

  • 2.11.0

[ GitHub ]

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

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

#to_s

Since:

  • 2.11.0

[ GitHub ]

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

def to_s
  super + notes_tail
end