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



41
42
43
44
45
# File 'lib/mongo/error/parser.rb', line 41

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

Instance Attribute Details

#documentBSON::Document (readonly)

Returns document The returned document.

Returns:

  • (BSON::Document)

    document The returned document.

Since:

  • 2.0.0



25
26
27
# File 'lib/mongo/error/parser.rb', line 25

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



28
29
30
# File 'lib/mongo/error/parser.rb', line 28

def message
  @message
end

#repliesArray<Protocol::Reply> (readonly)

Returns replies The message replies.

Returns:

Since:

  • 2.0.0



31
32
33
# File 'lib/mongo/error/parser.rb', line 31

def replies
  @replies
end