MongoDB C++ Driver  mongocxx-3.7.0
Public Member Functions | List of all members
mongocxx::operation_exception Class Reference

Class representing an exception received from a MongoDB server. More...

#include <operation_exception.hpp>

+ Inheritance diagram for mongocxx::operation_exception:

Public Member Functions

 operation_exception (std::error_code ec, bsoncxx::document::value &&raw_server_error, std::string what_arg="")
 Constructs a new operation exception. More...
 
bool has_error_label (stdx::string_view label) const
 Checks for the specified label in a operation exception. More...
 
const stdx::optional< bsoncxx::document::value > & raw_server_error () const
 The optional raw bson error document from the server. More...
 
stdx::optional< bsoncxx::document::value > & raw_server_error ()
 The optional raw bson error document from the server. More...
 

Detailed Description

Class representing an exception received from a MongoDB server.

It includes the server-provided error code, if one was available.

See also
mongocxx::exception

Constructor & Destructor Documentation

◆ operation_exception()

mongocxx::operation_exception::operation_exception ( std::error_code  ec,
bsoncxx::document::value &&  raw_server_error,
std::string  what_arg = "" 
)

Constructs a new operation exception.

Parameters
ecThe error code associated with this exception.
raw_server_errorThe optional raw bson error document to be associated with this exception.
what_argAn optional message to be returned by what.

Member Function Documentation

◆ has_error_label()

bool mongocxx::operation_exception::has_error_label ( stdx::string_view  label) const

Checks for the specified label in a operation exception.

Parameters
labelA string of the label to search for
Returns
True if the label is found in the operation exception, and false otherwise.

◆ raw_server_error() [1/2]

stdx::optional<bsoncxx::document::value>& mongocxx::operation_exception::raw_server_error ( )

The optional raw bson error document from the server.

Returns
The raw server error, if it is available.

◆ raw_server_error() [2/2]

const stdx::optional<bsoncxx::document::value>& mongocxx::operation_exception::raw_server_error ( ) const

The optional raw bson error document from the server.

Returns
The raw server error, if it is available.

The documentation for this class was generated from the following file: