2012-05-14 20:37:10 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2013-06-21 20:34:19 +00:00
|
|
|
#include <DB/IO/WriteHelpers.h>
|
2012-05-14 20:37:10 +00:00
|
|
|
|
2010-03-01 16:59:51 +00:00
|
|
|
#include <DB/Core/Exception.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2011-12-12 06:15:34 +00:00
|
|
|
|
|
|
|
Exception::Exception(int code): Poco::Exception(code) {}
|
|
|
|
Exception::Exception(const std::string & msg, int code) : Poco::Exception(msg, code) {}
|
|
|
|
Exception::Exception(const std::string & msg, const std::string & arg, int code): Poco::Exception(msg, arg, code) {}
|
|
|
|
Exception::Exception(const std::string & msg, const Exception & exc, int code): Poco::Exception(msg, exc, code), trace(exc.trace) {}
|
|
|
|
Exception::Exception(const Exception & exc) : Poco::Exception(exc), trace(exc.trace) {}
|
2012-10-15 19:29:17 +00:00
|
|
|
Exception::Exception(const Poco::Exception & exc) : Poco::Exception(exc.displayText()) {}
|
2011-12-12 06:15:34 +00:00
|
|
|
Exception::~Exception() throw() {}
|
|
|
|
|
|
|
|
Exception & Exception::operator=(const Exception& exc)
|
|
|
|
{
|
|
|
|
Poco::Exception::operator=(exc);
|
|
|
|
trace = exc.trace;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* Exception::name() const throw()
|
|
|
|
{
|
|
|
|
return "DB::Exception";
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* Exception::className() const throw()
|
|
|
|
{
|
|
|
|
return "DB::Exception";
|
|
|
|
}
|
|
|
|
|
|
|
|
Exception * Exception::clone() const
|
|
|
|
{
|
|
|
|
return new Exception(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Exception::rethrow() const
|
|
|
|
{
|
|
|
|
throw *this;
|
|
|
|
}
|
2010-03-01 16:59:51 +00:00
|
|
|
|
2012-05-14 20:37:10 +00:00
|
|
|
|
2012-11-15 11:59:39 +00:00
|
|
|
void throwFromErrno(const std::string & s, int code, int e)
|
2012-05-14 20:37:10 +00:00
|
|
|
{
|
|
|
|
char buf[128];
|
2013-06-21 20:34:19 +00:00
|
|
|
throw Exception(s + ", errno: " + toString(e) + ", strerror: " + std::string(strerror_r(e, buf, sizeof(buf))), code);
|
2012-05-14 20:37:10 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 16:59:51 +00:00
|
|
|
}
|