Classes | Namespaces | Defines | Enumerations | Functions

Error.h File Reference

#include "Common/String.h"
#include <ostream>
#include <stdexcept>
Include dependency graph for Error.h:

Go to the source code of this file.

Classes

struct  Hypertable::ExceptionMessageRenderer
struct  Hypertable::ExceptionMessagesRenderer
class  Hypertable::Exception
 This is a generic exception class for Hypertable. More...

Namespaces

namespace  Hypertable
 

Copyright (C) 2009 Doug Judd (Zvents, Inc.)


namespace  Hypertable::Error

Defines

#define HT_EXCEPTION(_code_, _msg_)   Exception(_code_, _msg_, __LINE__, HT_FUNC, __FILE__)
 Convenience macros to create an exception stack trace.
#define HT_EXCEPTION2(_code_, _ex_, _msg_)   Exception(_code_, _msg_, _ex_, __LINE__, HT_FUNC, __FILE__)
#define HT_THROW(_code_, _msg_)   throw HT_EXCEPTION(_code_, _msg_)
#define HT_THROW_(_code_)   HT_THROW(_code_, "")
#define HT_THROW2(_code_, _ex_, _msg_)   throw HT_EXCEPTION2(_code_, _ex_, _msg_)
#define HT_THROW2_(_code_, _ex_)   HT_THROW2(_code_, _ex_, "")
#define HT_THROWF(_code_, _fmt_,...)   throw HT_EXCEPTION(_code_, format(_fmt_, __VA_ARGS__))
#define HT_THROW2F(_code_, _ex_, _fmt_,...)   throw HT_EXCEPTION2(_code_, _ex_, format(_fmt_, __VA_ARGS__))
#define HT_RETHROWF(_fmt_,...)
#define HT_RETHROW(_s_)   HT_RETHROWF("%s", _s_)
#define HT_RETHROW_   HT_RETHROW("")
#define HT_TRY(_s_, _code_)
#define HT_LOG_EXCEPTION(_s_)
#define HT_TRY_OR_LOG(_s_, _code_)

Enumerations

enum  Hypertable::Error::Code {
  Hypertable::Error::UNPOSSIBLE = -3, Hypertable::Error::EXTERNAL = -2, Hypertable::Error::FAILED_EXPECTATION = -1, Hypertable::Error::OK = 0,
  Hypertable::Error::PROTOCOL_ERROR = 1, Hypertable::Error::REQUEST_TRUNCATED = 2, Hypertable::Error::RESPONSE_TRUNCATED = 3, Hypertable::Error::REQUEST_TIMEOUT = 4,
  Hypertable::Error::LOCAL_IO_ERROR = 5, Hypertable::Error::BAD_ROOT_LOCATION = 6, Hypertable::Error::BAD_SCHEMA = 7, Hypertable::Error::INVALID_METADATA = 8,
  Hypertable::Error::BAD_KEY = 9, Hypertable::Error::METADATA_NOT_FOUND = 10, Hypertable::Error::HQL_PARSE_ERROR = 11, Hypertable::Error::FILE_NOT_FOUND = 12,
  Hypertable::Error::BLOCK_COMPRESSOR_UNSUPPORTED_TYPE = 13, Hypertable::Error::BLOCK_COMPRESSOR_INVALID_ARG = 14, Hypertable::Error::BLOCK_COMPRESSOR_TRUNCATED = 15, Hypertable::Error::BLOCK_COMPRESSOR_BAD_HEADER = 16,
  Hypertable::Error::BLOCK_COMPRESSOR_BAD_MAGIC = 17, Hypertable::Error::BLOCK_COMPRESSOR_CHECKSUM_MISMATCH = 18, Hypertable::Error::BLOCK_COMPRESSOR_DEFLATE_ERROR = 19, Hypertable::Error::BLOCK_COMPRESSOR_INFLATE_ERROR = 20,
  Hypertable::Error::BLOCK_COMPRESSOR_INIT_ERROR = 21, Hypertable::Error::TABLE_NOT_FOUND = 22, Hypertable::Error::MALFORMED_REQUEST = 23, Hypertable::Error::TOO_MANY_COLUMNS = 24,
  Hypertable::Error::BAD_DOMAIN_NAME = 25, Hypertable::Error::COMMAND_PARSE_ERROR = 26, Hypertable::Error::CONNECT_ERROR_MASTER = 27, Hypertable::Error::CONNECT_ERROR_HYPERSPACE = 28,
  Hypertable::Error::BAD_MEMORY_ALLOCATION = 29, Hypertable::Error::BAD_SCAN_SPEC = 30, Hypertable::Error::NOT_IMPLEMENTED = 31, Hypertable::Error::VERSION_MISMATCH = 32,
  Hypertable::Error::CANCELLED = 33, Hypertable::Error::SCHEMA_PARSE_ERROR = 34, Hypertable::Error::SYNTAX_ERROR = 35, Hypertable::Error::DOUBLE_UNGET = 36,
  Hypertable::Error::EMPTY_BLOOMFILTER = 37, Hypertable::Error::BLOOMFILTER_CHECKSUM_MISMATCH = 38, Hypertable::Error::NAME_ALREADY_IN_USE = 39, Hypertable::Error::NAMESPACE_DOES_NOT_EXIST = 40,
  Hypertable::Error::BAD_NAMESPACE = 41, Hypertable::Error::NAMESPACE_EXISTS = 42, Hypertable::Error::NO_RESPONSE = 43, Hypertable::Error::NOT_ALLOWED = 44,
  Hypertable::Error::INDUCED_FAILURE = 45, Hypertable::Error::SERVER_SHUTTING_DOWN = 46, Hypertable::Error::CONFIG_BAD_ARGUMENT = 1001, Hypertable::Error::CONFIG_BAD_CFG_FILE = 1002,
  Hypertable::Error::CONFIG_GET_ERROR = 1003, Hypertable::Error::CONFIG_BAD_VALUE = 1004, Hypertable::Error::COMM_NOT_CONNECTED = 0x00010001, Hypertable::Error::COMM_BROKEN_CONNECTION = 0x00010002,
  Hypertable::Error::COMM_CONNECT_ERROR = 0x00010003, Hypertable::Error::COMM_ALREADY_CONNECTED = 0x00010004, Hypertable::Error::COMM_SEND_ERROR = 0x00010006, Hypertable::Error::COMM_RECEIVE_ERROR = 0x00010007,
  Hypertable::Error::COMM_POLL_ERROR = 0x00010008, Hypertable::Error::COMM_CONFLICTING_ADDRESS = 0x00010009, Hypertable::Error::COMM_SOCKET_ERROR = 0x0001000A, Hypertable::Error::COMM_BIND_ERROR = 0x0001000B,
  Hypertable::Error::COMM_LISTEN_ERROR = 0x0001000C, Hypertable::Error::COMM_HEADER_CHECKSUM_MISMATCH = 0x0001000D, Hypertable::Error::COMM_PAYLOAD_CHECKSUM_MISMATCH = 0x0001000E, Hypertable::Error::COMM_BAD_HEADER = 0x0001000F,
  Hypertable::Error::COMM_INVALID_PROXY = 0x00010010, Hypertable::Error::DFSBROKER_BAD_FILE_HANDLE = 0x00020001, Hypertable::Error::DFSBROKER_IO_ERROR = 0x00020002, Hypertable::Error::DFSBROKER_FILE_NOT_FOUND = 0x00020003,
  Hypertable::Error::DFSBROKER_BAD_FILENAME = 0x00020004, Hypertable::Error::DFSBROKER_PERMISSION_DENIED = 0x00020005, Hypertable::Error::DFSBROKER_INVALID_ARGUMENT = 0x00020006, Hypertable::Error::DFSBROKER_INVALID_CONFIG = 0x00020007,
  Hypertable::Error::DFSBROKER_EOF = 0x00020008, Hypertable::Error::HYPERSPACE_IO_ERROR = 0x00030001, Hypertable::Error::HYPERSPACE_CREATE_FAILED = 0x00030002, Hypertable::Error::HYPERSPACE_FILE_NOT_FOUND = 0x00030003,
  Hypertable::Error::HYPERSPACE_ATTR_NOT_FOUND = 0x00030004, Hypertable::Error::HYPERSPACE_DELETE_ERROR = 0x00030005, Hypertable::Error::HYPERSPACE_BAD_PATHNAME = 0x00030006, Hypertable::Error::HYPERSPACE_PERMISSION_DENIED = 0x00030007,
  Hypertable::Error::HYPERSPACE_EXPIRED_SESSION = 0x00030008, Hypertable::Error::HYPERSPACE_FILE_EXISTS = 0x00030009, Hypertable::Error::HYPERSPACE_IS_DIRECTORY = 0x0003000A, Hypertable::Error::HYPERSPACE_INVALID_HANDLE = 0x0003000B,
  Hypertable::Error::HYPERSPACE_REQUEST_CANCELLED = 0x0003000C, Hypertable::Error::HYPERSPACE_MODE_RESTRICTION = 0x0003000D, Hypertable::Error::HYPERSPACE_ALREADY_LOCKED = 0x0003000E, Hypertable::Error::HYPERSPACE_LOCK_CONFLICT = 0x0003000F,
  Hypertable::Error::HYPERSPACE_NOT_LOCKED = 0x00030010, Hypertable::Error::HYPERSPACE_BAD_ATTRIBUTE = 0x00030011, Hypertable::Error::HYPERSPACE_BERKELEYDB_ERROR = 0x00030012, Hypertable::Error::HYPERSPACE_DIR_NOT_EMPTY = 0x00030013,
  Hypertable::Error::HYPERSPACE_BERKELEYDB_DEADLOCK = 0x00030014, Hypertable::Error::HYPERSPACE_BERKELEYDB_REP_HANDLE_DEAD = 0x00030015, Hypertable::Error::HYPERSPACE_FILE_OPEN = 0x00030016, Hypertable::Error::HYPERSPACE_CLI_PARSE_ERROR = 0x00030017,
  Hypertable::Error::HYPERSPACE_CREATE_SESSION_FAILED = 0x00030018, Hypertable::Error::HYPERSPACE_NOT_MASTER_LOCATION = 0x00030019, Hypertable::Error::HYPERSPACE_STATEDB_ERROR = 0x0003001A, Hypertable::Error::HYPERSPACE_STATEDB_DEADLOCK = 0x0003001B,
  Hypertable::Error::HYPERSPACE_STATEDB_BAD_KEY = 0x0003001C, Hypertable::Error::HYPERSPACE_STATEDB_BAD_VALUE = 0x0003001D, Hypertable::Error::HYPERSPACE_STATEDB_ALREADY_DELETED = 0x0003001E, Hypertable::Error::HYPERSPACE_STATEDB_EVENT_EXISTS = 0x0003001F,
  Hypertable::Error::HYPERSPACE_STATEDB_EVENT_NOT_EXISTS = 0x00030020, Hypertable::Error::HYPERSPACE_STATEDB_EVENT_ATTR_NOT_FOUND = 0x00030021, Hypertable::Error::HYPERSPACE_STATEDB_SESSION_EXISTS = 0x00030022, Hypertable::Error::HYPERSPACE_STATEDB_SESSION_NOT_EXISTS = 0x00030023,
  Hypertable::Error::HYPERSPACE_STATEDB_SESSION_ATTR_NOT_FOUND = 0x00030024, Hypertable::Error::HYPERSPACE_STATEDB_HANDLE_EXISTS = 0x00030025, Hypertable::Error::HYPERSPACE_STATEDB_HANDLE_NOT_EXISTS = 0x00030026, Hypertable::Error::HYPERSPACE_STATEDB_HANDLE_ATTR_NOT_FOUND = 0x00030027,
  Hypertable::Error::HYPERSPACE_STATEDB_NODE_EXISTS = 0x00030028, Hypertable::Error::HYPERSPACE_STATEDB_NODE_NOT_EXISTS = 0x00030029, Hypertable::Error::HYPERSPACE_STATEDB_NODE_ATTR_NOT_FOUND = 0x0003002A, Hypertable::Error::MASTER_TABLE_EXISTS = 0x00040001,
  Hypertable::Error::MASTER_BAD_SCHEMA = 0x00040002, Hypertable::Error::MASTER_NOT_RUNNING = 0x00040003, Hypertable::Error::MASTER_NO_RANGESERVERS = 0x00040004, Hypertable::Error::MASTER_FILE_NOT_LOCKED = 0x00040005,
  Hypertable::Error::MASTER_RANGESERVER_ALREADY_REGISTERED = 0x00040006, Hypertable::Error::MASTER_BAD_COLUMN_FAMILY = 0x00040007, Hypertable::Error::MASTER_SCHEMA_GENERATION_MISMATCH = 0x00040008, Hypertable::Error::MASTER_LOCATION_ALREADY_ASSIGNED = 0x00040009,
  Hypertable::Error::MASTER_LOCATION_INVALID = 0x0004000A, Hypertable::Error::MASTER_OPERATION_IN_PROGRESS = 0x0004000B, Hypertable::Error::RANGESERVER_GENERATION_MISMATCH = 0x00050001, Hypertable::Error::RANGESERVER_RANGE_ALREADY_LOADED = 0x00050002,
  Hypertable::Error::RANGESERVER_RANGE_MISMATCH = 0x00050003, Hypertable::Error::RANGESERVER_NONEXISTENT_RANGE = 0x00050004, Hypertable::Error::RANGESERVER_OUT_OF_RANGE = 0x00050005, Hypertable::Error::RANGESERVER_RANGE_NOT_FOUND = 0x00050006,
  Hypertable::Error::RANGESERVER_INVALID_SCANNER_ID = 0x00050007, Hypertable::Error::RANGESERVER_SCHEMA_PARSE_ERROR = 0x00050008, Hypertable::Error::RANGESERVER_SCHEMA_INVALID_CFID = 0x00050009, Hypertable::Error::RANGESERVER_INVALID_COLUMNFAMILY = 0x0005000A,
  Hypertable::Error::RANGESERVER_TRUNCATED_COMMIT_LOG = 0x0005000B, Hypertable::Error::RANGESERVER_NO_METADATA_FOR_RANGE = 0x0005000C, Hypertable::Error::RANGESERVER_SHUTTING_DOWN = 0x0005000D, Hypertable::Error::RANGESERVER_CORRUPT_COMMIT_LOG = 0x0005000E,
  Hypertable::Error::RANGESERVER_UNAVAILABLE = 0x0005000F, Hypertable::Error::RANGESERVER_REVISION_ORDER_ERROR = 0x00050010, Hypertable::Error::RANGESERVER_ROW_OVERFLOW = 0x00050011, Hypertable::Error::RANGESERVER_TABLE_NOT_FOUND = 0x00050012,
  Hypertable::Error::RANGESERVER_BAD_SCAN_SPEC = 0x00050013, Hypertable::Error::RANGESERVER_CLOCK_SKEW = 0x00050014, Hypertable::Error::RANGESERVER_BAD_CELLSTORE_FILENAME = 0x00050015, Hypertable::Error::RANGESERVER_CORRUPT_CELLSTORE = 0x00050016,
  Hypertable::Error::RANGESERVER_TABLE_DROPPED = 0x00050017, Hypertable::Error::RANGESERVER_UNEXPECTED_TABLE_ID = 0x00050018, Hypertable::Error::RANGESERVER_RANGE_BUSY = 0x00050019, Hypertable::Error::RANGESERVER_BAD_CELL_INTERVAL = 0x0005001A,
  Hypertable::Error::RANGESERVER_SHORT_CELLSTORE_READ = 0x0005001B, Hypertable::Error::HQL_BAD_LOAD_FILE_FORMAT = 0x00060001, Hypertable::Error::METALOG_VERSION_MISMATCH = 0x00070001, Hypertable::Error::METALOG_BAD_RS_HEADER = 0x00070002,
  Hypertable::Error::METALOG_BAD_HEADER = 0x00070003, Hypertable::Error::METALOG_ENTRY_TRUNCATED = 0x00070004, Hypertable::Error::METALOG_CHECKSUM_MISMATCH = 0x00070005, Hypertable::Error::METALOG_ENTRY_BAD_TYPE = 0x00070006,
  Hypertable::Error::METALOG_ENTRY_BAD_ORDER = 0x00070007, Hypertable::Error::SERIALIZATION_INPUT_OVERRUN = 0x00080001, Hypertable::Error::SERIALIZATION_BAD_VINT = 0x00080002, Hypertable::Error::SERIALIZATION_BAD_VSTR = 0x00080003,
  Hypertable::Error::THRIFTBROKER_BAD_SCANNER_ID = 0x00090001, Hypertable::Error::THRIFTBROKER_BAD_MUTATOR_ID = 0x00090002, Hypertable::Error::THRIFTBROKER_BAD_NAMESPACE_ID = 0x00090003, Hypertable::Error::THRIFTBROKER_BAD_FUTURE_ID = 0x00090004
}

Functions

const char * Hypertable::Error::get_text (int error)
std::ostream & Hypertable::operator<< (std::ostream &out, const Exception &e)
std::ostream & Hypertable::operator<< (std::ostream &out, const ExceptionMessageRenderer &r)
std::ostream & Hypertable::operator<< (std::ostream &out, const ExceptionMessagesRenderer &r)

Define Documentation

#define HT_EXCEPTION (   _code_,
  _msg_ 
)    Exception(_code_, _msg_, __LINE__, HT_FUNC, __FILE__)

Convenience macros to create an exception stack trace.

Definition at line 328 of file Error.h.

#define HT_EXCEPTION2 (   _code_,
  _ex_,
  _msg_ 
)    Exception(_code_, _msg_, _ex_, __LINE__, HT_FUNC, __FILE__)

Definition at line 331 of file Error.h.

#define HT_LOG_EXCEPTION (   _s_ )
Value:
catch (Exception &e) { HT_ERROR_OUT << e <<", "<< _s_ << HT_END; } \
  catch (std::bad_alloc &e) { \
    HT_ERROR_OUT <<"Out of memory, "<< _s_ << HT_END; } \
  catch (std::exception &e) { \
    HT_ERROR_OUT <<"Caught exception: "<< e.what() <<", "<< _s_ << HT_END; } \
  catch (...) { \
    HT_ERROR_OUT <<"Caught unknown exception, "<< _s_ << HT_END; }

Definition at line 369 of file Error.h.

#define HT_RETHROW (   _s_ )    HT_RETHROWF("%s", _s_)

Definition at line 359 of file Error.h.

#define HT_RETHROW_   HT_RETHROW("")

Definition at line 360 of file Error.h.

#define HT_RETHROWF (   _fmt_,
  ... 
)
Value:
catch (Exception &e) { HT_THROW2F(e.code(), e, _fmt_, __VA_ARGS__); } \
  catch (std::bad_alloc &e) { \
    HT_THROWF(Error::BAD_MEMORY_ALLOCATION, _fmt_, __VA_ARGS__); \
  } \
  catch (std::exception &e) { \
    HT_THROWF(Error::EXTERNAL, "caught std::exception: %s " _fmt_,  e.what(), \
              __VA_ARGS__); \
  } \
  catch (...) { \
    HT_ERRORF("caught unknown exception " _fmt_, __VA_ARGS__); \
    throw; \
  }

Definition at line 345 of file Error.h.

#define HT_THROW (   _code_,
  _msg_ 
)    throw HT_EXCEPTION(_code_, _msg_)

Definition at line 334 of file Error.h.

#define HT_THROW2 (   _code_,
  _ex_,
  _msg_ 
)    throw HT_EXCEPTION2(_code_, _ex_, _msg_)

Definition at line 336 of file Error.h.

#define HT_THROW2_ (   _code_,
  _ex_ 
)    HT_THROW2(_code_, _ex_, "")

Definition at line 337 of file Error.h.

#define HT_THROW2F (   _code_,
  _ex_,
  _fmt_,
  ... 
)    throw HT_EXCEPTION2(_code_, _ex_, format(_fmt_, __VA_ARGS__))

Definition at line 342 of file Error.h.

#define HT_THROW_ (   _code_ )    HT_THROW(_code_, "")

Definition at line 335 of file Error.h.

#define HT_THROWF (   _code_,
  _fmt_,
  ... 
)    throw HT_EXCEPTION(_code_, format(_fmt_, __VA_ARGS__))

Definition at line 339 of file Error.h.

#define HT_TRY (   _s_,
  _code_ 
)
Value:
do { \
  try { _code_; } \
  HT_RETHROW(_s_) \
} while (0)

Definition at line 362 of file Error.h.

#define HT_TRY_OR_LOG (   _s_,
  _code_ 
)
Value:
do { \
  try { _code_; } \
  HT_LOG_EXCEPTION(_s_) \
} while (0)

Definition at line 378 of file Error.h.