forked from RoboCup-SSL/ssl-refbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exception.cc
36 lines (29 loc) · 869 Bytes
/
exception.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "exception.h"
#include <cerrno>
#include <cstring>
#include <sstream>
#ifdef WIN32
#include <ws2tcpip.h>
#else
#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
#endif
namespace {
std::string make_message(const std::string &message, int rc) {
std::ostringstream oss;
oss << message << ": " << std::strerror(rc);
return oss.str();
}
std::string make_gai_message(const std::string &message, int rc) {
std::ostringstream oss;
oss << message << ": " << gai_strerror(rc);
return oss.str();
}
}
SystemError::SystemError(const std::string &message) : std::runtime_error(make_message(message, errno)) {
}
SystemError::SystemError(const std::string &message, int rc) : std::runtime_error(make_message(message, rc)) {
}
GAIError::GAIError(const std::string &message, int rc) : std::runtime_error(make_gai_message(message, rc)) {
}