Added Exception ctor which takes both errNum and errorCode.

Also added DlAbortEx ctor which has same signature with new Exception
dtor.  Added DL_ABORT_EX3 macro to use added ctor.
pull/1/head
Tatsuhiro Tsujikawa 2010-11-28 22:30:06 +09:00
parent e8f3592314
commit ce6eb592da
6 changed files with 45 additions and 5 deletions

View File

@ -49,12 +49,18 @@ DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
const Exception& cause):
RecoverableException(file, line, msg, cause) {}
DlAbortEx::DlAbortEx
(const char* file, int line, int errNum, const std::string& msg):
RecoverableException(file, line, errNum, msg) {}
DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
error_code::Value code):
RecoverableException(file, line, msg, code) {}
DlAbortEx::DlAbortEx
(const char* file, int line, int errNum, const std::string& msg):
RecoverableException(file, line, errNum, msg) {}
DlAbortEx::DlAbortEx
(const char* file, int line, int errNum, const std::string& msg,
error_code::Value errorCode)
: RecoverableException(file, line, errNum, msg, errorCode)
{}
} // namespace aria2

View File

@ -47,14 +47,19 @@ public:
DlAbortEx(const char* file, int line, const std::string& msg,
const Exception& cause);
DlAbortEx(const char* file, int line, const std::string& msg,
error_code::Value code);
DlAbortEx(const char* file, int line, int errNum, const std::string& msg);
DlAbortEx(const char* file, int line, const std::string& msg,
DlAbortEx(const char* file, int line, int errNum, const std::string& msg,
error_code::Value code);
};
#define DL_ABORT_EX(arg) DlAbortEx(__FILE__, __LINE__, arg)
#define DL_ABORT_EX2(arg1, arg2) DlAbortEx(__FILE__, __LINE__, arg1, arg2)
#define DL_ABORT_EX3(arg1, arg2, arg3)\
DlAbortEx(__FILE__, __LINE__, arg1, arg2, arg3)
} // namespace aria2

View File

@ -86,6 +86,19 @@ Exception::Exception
errorCode_(error_code::UNKNOWN_ERROR)
{}
Exception::Exception
(const char* file,
int line,
int errNum,
const std::string& msg,
error_code::Value errorCode)
: file_(file),
line_(line),
errNum_(errNum),
msg_(msg),
errorCode_(errorCode)
{}
Exception::~Exception() throw() {}
std::string Exception::stackTrace() const

View File

@ -72,6 +72,9 @@ public:
Exception(const char* file, int line, int errNum, const std::string& msg);
Exception(const char* file, int line, int errNum, const std::string& msg,
error_code::Value errorCode);
virtual ~Exception() throw();
virtual const char* what() const throw();

View File

@ -64,4 +64,13 @@ RecoverableException::RecoverableException
: Exception(file, line, errNum, msg)
{}
RecoverableException::RecoverableException
(const char* file,
int line,
int errNum,
const std::string& msg,
error_code::Value errorCode)
: Exception(file, line, errNum, msg, errorCode)
{}
} // namespace aria2

View File

@ -52,6 +52,10 @@ public:
RecoverableException
(const char* file, int line, int errNum, const std::string& msg);
RecoverableException
(const char* file, int line, int errNum, const std::string& msg,
error_code::Value errorCode);
};
} // namespace aria2