00001 #ifndef DBALLE_CPP_ERROR_H
00002 #define DBALLE_CPP_ERROR_H
00003
00004 #include <dballe/core/error.h>
00005
00006 #include <string>
00007 #include <exception>
00008
00009 namespace dballe {
00010 namespace exception {
00011
00015 class Exception : public std::exception
00016 {
00018 dba_err_code code;
00020 std::string message;
00022 std::string context;
00024 std::string details;
00026 std::string fullInfo;
00027
00028 public:
00029 Exception();
00030 virtual ~Exception() throw () {}
00031
00033 virtual const char* what() const throw ()
00034 {
00035 return fullInfo.c_str();
00036 }
00037 };
00038
00043 struct NotFound : public Exception {};
00044 struct Type : public Exception {};
00045 struct Alloc : public Exception {};
00046 struct ODBC : public Exception {};
00047 struct Handles : public Exception {};
00048 struct TooLong : public Exception {};
00049 struct System : public Exception {};
00050 struct Consistency : public Exception {};
00051 struct Parse : public Exception {};
00052 struct Write : public Exception {};
00053 struct Regex : public Exception {};
00054 struct Unimplemented : public Exception {};
00060 void throwAppropriateException();
00061
00062 }
00063
00067 static inline void checked(dba_err err)
00068 {
00069 if (err != DBA_OK)
00070 dballe::exception::throwAppropriateException();
00071 }
00072
00073 }
00074
00075 #endif