Module: Mongo::Error::Notable Private

Included in:
Mongo::Error, AuthError
Defined in:
lib/mongo/error/notable.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connection_global_idInteger | nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns global id of the connection on which the error occurred.

Returns:

  • Connection global id.

Since:

  • 2.11.0

API:

  • private



78
79
80
# File 'lib/mongo/error/notable.rb', line 78

def connection_global_id
  @connection_global_id
end

#generationInteger | nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns connection pool generation for the connection on which the error occurred.

Returns:

  • Connection pool generation.

Since:

  • 2.11.0

API:

  • private



64
65
66
# File 'lib/mongo/error/notable.rb', line 64

def generation
  @generation
end

#service_idObject | nil

Returns service id for the connection on which the error occurred.

Returns:

  • Service id.

Since:

  • 2.11.0

API:

  • experimental



71
72
73
# File 'lib/mongo/error/notable.rb', line 71

def service_id
  @service_id
end

Instance Method Details

#add_note(note) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.11.0

API:

  • private



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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

#notesArray<String>

Returns an array of strings with additional information about the exception.

Returns:

  • Additional information strings.

Since:

  • 2.11.0

API:

  • public



36
37
38
39
40
41
42
# File 'lib/mongo/error/notable.rb', line 36

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

#to_sObject

Since:

  • 2.11.0

API:

  • public



81
82
83
# File 'lib/mongo/error/notable.rb', line 81

def to_s
  super + notes_tail
end