module Mongo::Error::Notable

A module encapsulating note tracking functionality, since currently the driver does not have a single exception hierarchy root.

@since 2.11.0 @api private

Public Instance Methods

add_note(note) click to toggle source

@api private

# File lib/mongo/error/notable.rb, line 41
def add_note(note)
  unless @notes
    @notes = []
  end
  @notes << note
end
inspect() click to toggle source

@api public

Calls superclass method
# File lib/mongo/error/notable.rb, line 59
def inspect
  msg = super
  if msg.end_with?('>')
    msg[0...msg.length-1] + notes_tail + '>'
  else
    msg + notes_tail
  end
end
message() click to toggle source

@api public

Calls superclass method
# File lib/mongo/error/notable.rb, line 49
def message
  super + notes_tail
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 32
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 54
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 71
def notes_tail
  msg = ''
  unless notes.empty?
    msg += " (#{notes.join(', ')})"
  end
  msg
end