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
generation[RW]
Returns connection pool generation for the connection on which the error occurred.
@return [ Integer | nil ] Connection pool generation.
service_id[RW]
Returns service id for the connection on which the error occurred.
@return [ Object | nil ] Service id.
@api experimental
Public Instance Methods
add_note(note)
click to toggle source
@api private
# 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
notes()
click to toggle source
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 36 def notes if @notes @notes.dup else [] end end
to_s()
click to toggle source
@api public
Calls superclass method
# File lib/mongo/error/notable.rb, line 74 def to_s super + notes_tail end
Private Instance Methods
notes_tail()
click to toggle source
@api private
# File lib/mongo/error/notable.rb, line 81 def notes_tail msg = '' unless notes.empty? msg += " (#{notes.join(', ')})" end msg end