21#include "mongo/base/error_codes.h"
22#include "mongo/client/export_macros.h"
23#include "mongo/platform/atomic_word.h"
53 static inline Status MONGO_CLIENT_FUNC OK();
60 Status(ErrorCodes::Error code,
const std::string& reason,
int location = 0);
61 Status(ErrorCodes::Error code,
const char* reason,
int location = 0);
66#if __cplusplus >= 201103L
78 bool operator==(
const Status& other)
const;
79 bool operator!=(
const Status& other)
const;
86 bool operator==(
const ErrorCodes::Error other)
const;
87 bool operator!=(
const ErrorCodes::Error other)
const;
93 inline bool isOK()
const;
95 inline ErrorCodes::Error code()
const;
97 inline std::string codeString()
const;
99 inline std::string reason()
const;
101 inline int location()
const;
103 std::string toString()
const;
109 inline AtomicUInt32::WordType refCount()
const;
116 const ErrorCodes::Error code;
117 const std::string reason;
120 static ErrorInfo* create(ErrorCodes::Error code,
const StringData& reason,
int location);
122 ErrorInfo(ErrorCodes::Error code,
const StringData& reason,
int location);
132 static inline void MONGO_CLIENT_FUNC ref(ErrorInfo* error);
133 static inline void MONGO_CLIENT_FUNC unref(ErrorInfo* error);
136MONGO_CLIENT_API
inline bool MONGO_CLIENT_FUNC
137operator==(
const ErrorCodes::Error lhs,
const Status& rhs);
139MONGO_CLIENT_API
inline bool MONGO_CLIENT_FUNC
140operator!=(
const ErrorCodes::Error lhs,
const Status& rhs);
146MONGO_CLIENT_API std::ostream& MONGO_CLIENT_FUNC operator<<(std::ostream& os,
const Status& status);
147MONGO_CLIENT_API std::ostream& MONGO_CLIENT_FUNC operator<<(std::ostream& os, ErrorCodes::Error);
151#include "mongo/base/status-inl.h"
Status represents an error state or the absence thereof.
Definition status.h:50
Status(ErrorCodes::Error code, const std::string &reason, int location=0)
Builds an error status given the error code, a textual description of what caused the error,...
bool compare(const Status &other) const
Returns true if 'other's error code and location are equal/different to this instance's.
bool compareCode(const ErrorCodes::Error other) const
Returns true if 'other's error code is equal/different to this instance's.
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents.
Definition string_data.h:43
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:20