module Mongo::Error::Notable
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 @api private
Attributes
Returns global id of the connection on which the error occurred.
@return [ Integer | nil ] Connection global id.
@api private
Returns connection pool generation for the connection on which the error occurred.
@return [ Integer | nil ] Connection pool generation.
Returns service id for the connection on which the error occurred.
@return [ Object | nil ] Service id.
@api experimental
Public Instance Methods
@api private
# File lib/mongo/error/notable.rb, line 44 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
Allows multiple notes to be added in a single call, for convenience.
@api private
# File lib/mongo/error/notable.rb, line 62 def add_notes(*notes) notes.each { |note| add_note(note) } end
Returns an array of strings with additional information about the exception.
@return [ Array<String> ] Additional information strings.
@since 2.11.0 @api public
# File lib/mongo/error/notable.rb, line 35 def notes if @notes @notes.dup else [] end end
@api public
# File lib/mongo/error/notable.rb, line 87 def to_s super + notes_tail end
Private Instance Methods
@api private
# File lib/mongo/error/notable.rb, line 94 def notes_tail msg = '' unless notes.empty? msg += " (#{notes.join(', ')})" end msg end