Class: Mongo::Error::Parser

Inherits:
Object
  • Object
show all
Includes:
SdamErrorDetection
Defined in:
lib/mongo/error/parser.rb

Overview

Class for parsing the various forms that errors can come in from MongoDB command responses.

Since:

  • 2.0.0

Constant Summary

Constants included from SdamErrorDetection

SdamErrorDetection::NODE_RECOVERING_CODES, SdamErrorDetection::NOT_MASTER_CODES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SdamErrorDetection

#node_recovering?, #not_master?

Constructor Details

#initialize(document, replies = nil) ⇒ Parser

Create the new parser with the returned document.

Examples:

Create the new parser.

Parser.new({ 'errmsg' => 'failed' })

Parameters:

  • document (BSON::Document)

    The returned document.

Since:

  • 2.0.0



81
82
83
84
85
# File 'lib/mongo/error/parser.rb', line 81

def initialize(document, replies = nil)
  @document = document || {}
  @replies = replies
  parse!
end

Instance Attribute Details

#codeInteger (readonly)

Returns code The error code parsed from the document.

Returns:

  • (Integer)

    code The error code parsed from the document.

Since:

  • 2.6.0



60
61
62
# File 'lib/mongo/error/parser.rb', line 60

def code
  @code
end

#code_nameString (readonly)

Returns code_name The error code name parsed from the document.

Returns:

  • (String)

    code_name The error code name parsed from the document.

Since:

  • 2.6.0



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

def code_name
  @code_name
end

#documentBSON::Document (readonly)

Returns document The returned document.

Returns:

  • (BSON::Document)

    document The returned document.

Since:

  • 2.0.0



50
51
52
# File 'lib/mongo/error/parser.rb', line 50

def document
  @document
end

#labelsArray<String> (readonly)

Returns labels The set of labels associated with the error.

Returns:

  • (Array<String>)

    labels The set of labels associated with the error.

Since:

  • 2.7.0



68
69
70
# File 'lib/mongo/error/parser.rb', line 68

def labels
  @labels
end

#messageString (readonly)

Returns message The error message parsed from the document.

Returns:

  • (String)

    message The error message parsed from the document.

Since:

  • 2.0.0



53
54
55
# File 'lib/mongo/error/parser.rb', line 53

def message
  @message
end

#repliesArray<Protocol::Message> (readonly)

Returns replies The message replies.

Returns:

Since:

  • 2.0.0



56
57
58
# File 'lib/mongo/error/parser.rb', line 56

def replies
  @replies
end

#wtimeoutObject (readonly)

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.0.0



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

def wtimeout
  @wtimeout
end