mirror of https://github.com/aria2/aria2
2010-10-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added errno member variable to Exception. * src/DlAbortEx.cc * src/DlAbortEx.h * src/Exception.cc * src/Exception.h * src/RecoverableException.cc * src/RecoverableException.hpull/1/head
parent
8bfe35d3f2
commit
4ddc6eac58
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2010-10-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added errno member variable to Exception.
|
||||
* src/DlAbortEx.cc
|
||||
* src/DlAbortEx.h
|
||||
* src/Exception.cc
|
||||
* src/Exception.h
|
||||
* src/RecoverableException.cc
|
||||
* src/RecoverableException.h
|
||||
|
||||
2010-10-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Simplified directory creation.
|
||||
|
|
|
@ -52,6 +52,10 @@ DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
|
|||
DlAbortEx::DlAbortEx(const char* file, int line, const RecoverableException& e):
|
||||
RecoverableException(file, line, e) {}
|
||||
|
||||
DlAbortEx::DlAbortEx
|
||||
(const char* file, int line, int errnoArg, const std::string& msg):
|
||||
RecoverableException(file, line, errnoArg, msg) {}
|
||||
|
||||
DlAbortEx::DlAbortEx(const char* file, int line, const std::string& msg,
|
||||
downloadresultcode::RESULT code):
|
||||
RecoverableException(file, line, msg, code) {}
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
|
||||
DlAbortEx(const char* file, int line, const RecoverableException& e);
|
||||
|
||||
DlAbortEx(const char* file, int line, int errnoArg, const std::string& msg);
|
||||
|
||||
DlAbortEx(const char* file, int line, const std::string& msg,
|
||||
downloadresultcode::RESULT code);
|
||||
};
|
||||
|
|
|
@ -39,27 +39,30 @@
|
|||
namespace aria2 {
|
||||
|
||||
Exception::Exception(const char* file, int line, const std::string& msg):
|
||||
file_(file), line_(line), msg_(msg) {}
|
||||
file_(file), line_(line), errno_(0), msg_(msg) {}
|
||||
|
||||
Exception::Exception(const char* file, int line, const std::string& msg,
|
||||
const Exception& cause):
|
||||
file_(file), line_(line), msg_(msg), cause_(cause.copy()) {}
|
||||
file_(file), line_(line), errno_(0), msg_(msg), cause_(cause.copy()) {}
|
||||
|
||||
Exception::Exception(const char* file, int line, const Exception& e):
|
||||
file_(file), line_(line), msg_(e.msg_), cause_(e.cause_)
|
||||
file_(file), line_(line), errno_(0), msg_(e.msg_), cause_(e.cause_)
|
||||
{}
|
||||
|
||||
Exception::Exception
|
||||
(const char* file, int line, int errnoArg, const std::string& msg):
|
||||
file_(file), line_(line), errno_(errnoArg), msg_(msg) {}
|
||||
|
||||
Exception::~Exception() throw() {}
|
||||
|
||||
const char* Exception::what() const throw()
|
||||
{
|
||||
return msg_.c_str();
|
||||
}
|
||||
|
||||
std::string Exception::stackTrace() const throw()
|
||||
std::string Exception::stackTrace() const
|
||||
{
|
||||
std::stringstream s;
|
||||
s << "Exception: " << "[" << file_ << ":" << line_ << "] " << what() << "\n";
|
||||
s << "Exception: " << "[" << file_ << ":" << line_ << "] ";
|
||||
if(errno_) {
|
||||
s << "errno=" << errno_ << " ";
|
||||
}
|
||||
s << what() << "\n";
|
||||
SharedHandle<Exception> e = cause_;
|
||||
while(!e.isNull()) {
|
||||
s << " -> " << "[" << e->file_ << ":" << e->line_ << "] "
|
||||
|
|
|
@ -36,9 +36,12 @@
|
|||
#define _D_EXCEPTION_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "SharedHandle.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <string>
|
||||
|
||||
#include "SharedHandle.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
class Exception:public std::exception {
|
||||
|
@ -47,6 +50,8 @@ private:
|
|||
|
||||
int line_;
|
||||
|
||||
int errno_;
|
||||
|
||||
std::string msg_;
|
||||
|
||||
SharedHandle<Exception> cause_;
|
||||
|
@ -62,11 +67,21 @@ public:
|
|||
|
||||
Exception(const char* file, int line, const Exception& e);
|
||||
|
||||
Exception(const char* file, int line, int errnoArg, const std::string& msg);
|
||||
|
||||
virtual ~Exception() throw();
|
||||
|
||||
virtual const char* what() const throw();
|
||||
virtual const char* what() const throw()
|
||||
{
|
||||
return msg_.c_str();
|
||||
}
|
||||
|
||||
std::string stackTrace() const throw();
|
||||
std::string stackTrace() const;
|
||||
|
||||
int getErrno() const
|
||||
{
|
||||
return errno_;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -59,6 +59,11 @@ RecoverableException::RecoverableException
|
|||
Exception(file, line, e),
|
||||
code_(downloadresultcode::UNKNOWN_ERROR) {}
|
||||
|
||||
RecoverableException::RecoverableException
|
||||
(const char* file, int line, int errnoArg, const std::string& msg):
|
||||
Exception(file, line, errnoArg, msg),
|
||||
code_(downloadresultcode::UNKNOWN_ERROR) {}
|
||||
|
||||
RecoverableException::RecoverableException
|
||||
(const char* file, int line, const std::string& msg,
|
||||
downloadresultcode::RESULT result):
|
||||
|
|
|
@ -54,6 +54,9 @@ public:
|
|||
RecoverableException(const char* file, int line,
|
||||
const RecoverableException& e);
|
||||
|
||||
RecoverableException
|
||||
(const char* file, int line, int errnoArg, const std::string& msg);
|
||||
|
||||
RecoverableException(const char* file, int line, const std::string& msg,
|
||||
downloadresultcode::RESULT result);
|
||||
|
||||
|
|
Loading…
Reference in New Issue