congestvpn/util.cpp

22 lines
421 B
C++

#include <cstdio>
#include <string.h>
#include "util.hpp"
MsgException::MsgException(const std::string& msg, int code, bool is_perror)
: _msg(msg), _code(code)
{
_what = _msg;
if(_code != 0) {
if(is_perror) {
_what += ": ";
_what += strerror(errno);
}
char remainder[20];
sprintf(remainder, " (code %d)", _code);
_what += remainder;
}
}