Zero  0.1.0
Classes | Macros | Functions
kits_exception.h File Reference
#include <exception>
#include <cstring>
#include <cerrno>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <sstream>

Go to the source code of this file.

Classes

class  ZappsException
 
class  QPipeException
 
class  ThreadException
 

Macros

#define EXCEPTION(type)   type(__FILE__, __LINE__, __PRETTY_FUNCTION__)
 Without VA_ARGS. More...
 
#define EXCEPTION1(type, arg)   type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg))
 
#define EXCEPTION2(type, arg1, arg2)   type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2))
 
#define THROW(type)
 
#define THROW1(type, arg)
 
#define THROW2(type, arg1, arg2)
 
#define THROW3(type, arg1, arg2, arg3)
 
#define THROW4(type, arg1, arg2, arg3, arg4)
 
#define THROW_IF(Exception, err)
 
#define DEFINE_EXCEPTION(Name)
 
#define unreachable()   THROW(Unreachable)
 

Functions

std::string errno_to_str (int err=errno)
 
 DEFINE_EXCEPTION (Unreachable)
 
 DEFINE_EXCEPTION (BadAlloc)
 
 DEFINE_EXCEPTION (OutOfRange)
 
 DEFINE_EXCEPTION (FileException)
 
 DEFINE_EXCEPTION (BdbException)
 

Macro Definition Documentation

§ DEFINE_EXCEPTION

#define DEFINE_EXCEPTION (   Name)
Value:
class Name : public ZappsException { \
public: \
Name(const char* filename, int line_num, const char* function_name, \
const char* m) \
: ZappsException(filename, line_num, function_name, m) \
{ \
} \
}
Definition: kits_exception.h:71
ZappsException(const char *filename, int line_num, const char *function_name, std::string const &m)
Definition: kits_exception.h:78

§ EXCEPTION

#define EXCEPTION (   type)    type(__FILE__, __LINE__, __PRETTY_FUNCTION__)

Without VA_ARGS.

§ EXCEPTION1

#define EXCEPTION1 (   type,
  arg 
)    type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg))

§ EXCEPTION2

#define EXCEPTION2 (   type,
  arg1,
  arg2 
)    type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2))

§ THROW

#define THROW (   type)
Value:
do { \
assert(false); \
throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, ""); \
} while (false)
#define __PRETTY_FUNCTION__
Definition: compat.h:34

§ THROW1

#define THROW1 (   type,
  arg 
)
Value:
do { \
fprintf(stderr, arg.c_str()); \
fflush(stderr); \
assert(false); \
throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, arg.c_str()); \
} while (false)
#define __PRETTY_FUNCTION__
Definition: compat.h:34

§ THROW2

#define THROW2 (   type,
  arg1,
  arg2 
)
Value:
do { \
fprintf(stderr, arg1, arg2); \
fflush(stderr); \
assert(false); \
throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2)); \
} while (false)
#define __PRETTY_FUNCTION__
Definition: compat.h:34

§ THROW3

#define THROW3 (   type,
  arg1,
  arg2,
  arg3 
)
Value:
do { \
fprintf(stderr, arg1, arg2, arg3); \
fflush(stderr); \
assert(false); \
throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2, arg3)); \
} while (false)
#define __PRETTY_FUNCTION__
Definition: compat.h:34

§ THROW4

#define THROW4 (   type,
  arg1,
  arg2,
  arg3,
  arg4 
)
Value:
do { \
fprintf(stderr, arg1, arg2, arg3, arg4); \
fflush(stderr); \
assert(false); \
throw type(__FILE__, __LINE__, __PRETTY_FUNCTION__, std::string(arg1, arg2, arg3, arg4)); \
} while (false)
#define __PRETTY_FUNCTION__
Definition: compat.h:34

§ THROW_IF

#define THROW_IF (   Exception,
  err 
)
Value:
do { \
assert(!err); \
if(err) { \
THROW1(Exception, errno_to_str(err)); \
} \
} while (false)
std::string errno_to_str(int err=errno)
Definition: kits_exception.h:114

§ unreachable

#define unreachable ( )    THROW(Unreachable)

Function Documentation

§ DEFINE_EXCEPTION() [1/5]

DEFINE_EXCEPTION ( Unreachable  )

§ DEFINE_EXCEPTION() [2/5]

DEFINE_EXCEPTION ( BadAlloc  )

§ DEFINE_EXCEPTION() [3/5]

DEFINE_EXCEPTION ( OutOfRange  )

§ DEFINE_EXCEPTION() [4/5]

DEFINE_EXCEPTION ( FileException  )

§ DEFINE_EXCEPTION() [5/5]

DEFINE_EXCEPTION ( BdbException  )

§ errno_to_str()

std::string errno_to_str ( int  err = errno)
inline