ClickHouse/libs/libzkutil/include/zkutil/KeeperException.h

29 lines
908 B
C
Raw Normal View History

2014-03-07 13:50:58 +00:00
#pragma once
#include <statdaemons/Exception.h>
#include <zkutil/Types.h>
2014-03-07 13:50:58 +00:00
namespace zkutil
{
class KeeperException : public DB::Exception
2014-03-07 13:50:58 +00:00
{
public:
KeeperException(const std::string & msg) : DB::Exception(msg), code(ZOK) {}
KeeperException(const std::string & msg, int32_t code_)
: DB::Exception(msg + " (" + zerror(code_) + ")"), code(code_) {}
KeeperException(int32_t code_)
: DB::Exception(zerror(code_)), code(code_) {}
KeeperException(int32_t code_, const std::string & path_)
: DB::Exception(std::string(zerror(code_)) + " path: " + path_), code(code_) {}
KeeperException(const KeeperException & exc) : DB::Exception(exc), code(exc.code) {}
2014-03-07 13:50:58 +00:00
2014-04-02 13:45:39 +00:00
const char * name() const throw() { return "zkutil::KeeperException"; }
const char * className() const throw() { return "zkutil::KeeperException"; }
KeeperException * clone() const { return new KeeperException(*this); }
2014-04-02 13:45:39 +00:00
int32_t code;
2014-03-07 13:50:58 +00:00
};
};