/* */ #ifndef _D_EXCEPTION_H_ #define _D_EXCEPTION_H_ #include "common.h" #include #include #include #include namespace aria2 { class Exception { private: std::string msg; protected: Exception* cause; void setMsg(const std::string& msgsrc, va_list ap) { char buf[1024]; vsnprintf(buf, sizeof(buf), msgsrc.c_str(), ap); msg = buf; } public: Exception(Exception* cause = 0):cause(cause) {} virtual ~Exception() { delete cause; } const std::string& getMsg() const { return msg; } Exception* getCause() const { return cause; } friend std::ostream& operator<<(std::ostream& o, const Exception& e); }; } // namespace aria2 #endif // _D_EXCEPTION_H_