42 const char * type_,
const char * error_string_)
43 : msg(msg_), context(context_), error_string(), type(type_),
44 my_errno(0), already_handled(
false)
52 if (error_string.empty()) {
53 if (my_errno == 0)
return NULL;
55 if (my_errno < 0 || my_errno >= WSABASEERR) {
56 int e = abs(my_errno);
59 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|
60 FORMAT_MESSAGE_ALLOCATE_BUFFER,
61 0, e, 0, (CHAR*)&error, 0, 0);
64 if (len >= 2 && memcmp(error + len - 2,
"\r\n", 2) == 0)
66 error_string.assign(error, len);
69 error_string =
"Unknown Error ";
70 error_string +=
str(e);
83 error_string.assign(gai_strerror(-my_errno));
85 error_string.assign(gai_strerror(my_errno));
89 return error_string.c_str();
95 string desc(get_type());
98 if (!context.empty()) {
99 desc +=
" (context: ";
103 const char *e = get_error_string();
std::string error_string
The error string derived from my_errno.
const char * get_error_string() const
Returns any system error string associated with this exception.
Error(const std::string &msg_, const std::string &context_, const char *type_, const char *error_string_)
Constructor for use by constructors of derived classes.
std::string get_description() const
Return a string describing this object.
Append a string to an object description, escaping invalid UTF-8.
void errno_to_string(int e, string &s)
Convert errno value to std::string, thread-safe if possible.
Hierarchy of classes which Xapian can throw as exceptions.
string str(int value)
Convert int to std::string.
include <netdb.h>, with portability workarounds.
include <windows.h> without all the bloat and damage.
Convert types to std::string.
void description_append(std::string &desc, const std::string &s)