123456789_123456789_123456789_123456789_123456789_

Module: Mongo::Error::Labelable

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
::Mongo::Auth::Unauthorized, ::Mongo::Error, BadLoadBalancerTarget, BulkWriteError, ClientClosed, ClosedStream, ConnectionPerished, ConnectionUnavailable, CryptError, ExtraFileChunk, FailedStringPrepValidation, FileNotFound, HandshakeError, InsufficientIterationCount, InternalDriverError, InvalidAddress, InvalidApplicationName, InvalidBulkOperation, InvalidBulkOperationType, InvalidCollectionName, InvalidConfigOption, InvalidCursorOperation, InvalidDatabaseName, InvalidDocument, InvalidFile, InvalidFileRevision, InvalidMaxConnecting, InvalidMinPoolSize, InvalidNonce, InvalidReadConcern, InvalidReadOption, InvalidReplacementDocument, 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/labelable.rb

Overview

Note:

Although methods of this module are part of the public API, the fact that these methods are defined on this module and not on the classes which include this module is not part of the public API.

A module encapsulating functionality to manage labels added to errors.

Since:

  • 2.0.0

Instance Method Summary

Instance Method Details

#add_label(label)

This method is for internal use only.

Adds the specified label to the error instance, if the label is not already in the set of labels.

Parameters:

  • label (String)

    The label to add.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/error/labelable.rb', line 66

def add_label(label)
  @labels ||= []
  @labels << label unless label?(label)
end

#label?(label) ⇒ true, false

Does the error have the given label?

Examples:

error.label?(label)

Parameters:

  • label (String)

    The label to check if the error has.

Returns:

  • (true, false)

    Whether the error has the given label.

Since:

  • 2.6.0

[ GitHub ]

  
# File 'lib/mongo/error/labelable.rb', line 40

def label?(label)
  @labels && @labels.include?(label)
end

#labelsArray

Gets the set of labels associated with the error.

Examples:

error.labels

Returns:

  • (Array)

    The set of labels.

Since:

  • 2.7.0

[ GitHub ]

  
# File 'lib/mongo/error/labelable.rb', line 52

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