11 #ifndef __MOZOPC_EXCEPTION__H__ 12 #define __MOZOPC_EXCEPTION__H__ 15 #include <boost/format.hpp> 42 class Error :
public std::exception
46 explicit Error(
unsigned lineNum,
const char * fileName,
unsigned errorCode,
const char * msg);
47 virtual ~
Error()
throw();
49 unsigned GetLineNum()
const;
51 unsigned GetCode()
const;
58 virtual const char *
what()
const throw();
72 const char * filename,
79 template <
typename T1>
82 const char * fileName,
88 return Error(lineNum, fileName, errorCode, resultMessage.c_str());
91 template <
typename T1>
94 const char * fileName,
101 Error resultError(lineNum, fileName, errorCode, resultMessage.c_str());
106 template <
typename T1,
typename T2>
109 const char * fileName,
116 return Error(lineNum, fileName, errorCode, resultMessage.c_str());
120 template <
typename T1,
typename T2>
123 const char * fileName,
131 Error resultError(lineNum, fileName, errorCode, resultMessage.c_str());
136 template <
typename T1,
typename T2,
typename T3>
139 const char * fileName,
147 return Error(lineNum, fileName, errorCode, resultMessage.c_str());
150 template <
typename T1,
typename T2,
typename T3>
153 const char * fileName,
162 Error resultError(lineNum, fileName, errorCode, resultMessage.c_str());
167 template <
typename T1,
typename T2,
typename T3,
typename T4>
170 const char * fileName,
179 return Error(lineNum, fileName, errorCode, resultMessage.c_str());
182 template <
typename T1,
typename T2,
typename T3,
typename T4>
185 const char * fileName,
195 Error resultError(lineNum, fileName, errorCode, resultMessage.c_str());
203 #define ERROR_CODE(module_id, code) (module_id << 16 | (code & 8)) 205 #define THROW_COMMON_ERROR(code, message) throw ::Common::CreateError(__LINE__, __FILE__, code, message) 206 #define CREATE_COMMON_ERROR(code, message) Common::CreateError(__LINE__, __FILE__, code, message) 207 #define THROW_ERROR(data) throw ::Common::CreateError(__LINE__, __FILE__, data.ErrorCode, data.ErrorMessage) 208 #define CREATE_ERROR(data) ::Common::CreateError(__LINE__, __FILE__, data.ErrorCode, data.ErrorMessage) 211 #define CREATE_ERROR1(data, param1) (::Common::CreateError(__LINE__, __FILE__, data.ErrorCode, data.ErrorMessage, param1)) 212 #define THROW_ERROR1(data, param1) throw CREATE_ERROR1(data, param1); 214 #define CREATE_ERROR2(data, param1, param2) ::Common::CreateError(__LINE__, __FILE__, data.ErrorCode, data.ErrorMessage, param1, param2) 215 #define THROW_ERROR2(data, param1, param2) throw CREATE_ERROR2(data, param1, param2) 217 #define CREATE_ERROR3(data, param1, param2, param3) ::Common::CreateError(__LINE__, __FILE__, data.ErrorCode, data.ErrorMessage, param1, param2, param3) 218 #define THROW_ERROR3(data, param1, param2, param3) throw CREATE_ERROR3(data, param1, param2, param3) 220 #define CREATE_ERROR4(data, param1, param2, param3, param4) ::Common::CreateError(__LINE__, __FILE__, data.ErrorCode, data.ErrorMessage, param1, param2, param3, param4) 221 #define THROW_ERROR4(data, param1, param2, param3, param4) throw CREATE_ERROR4(data, param1, param2, param3, param4) 226 #define THROW_OS_ERROR(UserMsg) (throw ::Common::CreateError(__LINE__, __FILE__, errno, "%1% %2%.", UserMsg, strerror(errno))) 228 #define BEGIN_TRY_BLOCK try{ 229 #define END_TRY_BLOCK(handler)\ 231 catch (const ::Common::Error& err)\ 233 return handler(err);\ 235 catch (const std::exception& exc)\ 237 return handler(CREATE_ERROR1(StdException, exc.what()));\ 240 #endif // __MOZOPC_EXCEPTION__H__ Addon interface definition GNU LGPL.
std::string format(CStringRef format_str, ArgList args)
const char * ErrorMessage
Error & AddError(const Error &subError)
Error CreateError(unsigned lineNum, const char *filename, unsigned errorCode, const char *msg)
ErrorData(unsigned code, const char *msg)
std::vector< Error > SubErrors