Class: Mongo::Error::Parser

Inherits:
Object
  • Object
show all
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

Instance Attribute Summary collapse

Instance Method Summary collapse

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



73
74
75
76
77
# File 'lib/mongo/error/parser.rb', line 73

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



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

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



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

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



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

def document
  @document
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



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

def message
  @message
end

#repliesArray<Protocol::Message> (readonly)

Returns replies The message replies.

Returns:

Since:

  • 2.0.0



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

def replies
  @replies
end