/* */ #include "Exception.h" #include namespace aria2 { Exception::Exception(const char* file, int line, const std::string& msg): _file(file), _line(line), _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()) {} Exception::Exception(const char* file, int line, const Exception& e): _file(file), _line(line), _msg(e._msg), _cause(e._cause) {} Exception::~Exception() throw() {} const char* Exception::what() const throw() { return _msg.c_str(); } std::string Exception::stackTrace() const throw() { std::stringstream s; s << "Exception: " << "[" << _file << ":" << _line << "] " << what() << "\n"; SharedHandle e = _cause; while(!e.isNull()) { s << " -> " << "[" << e->_file << ":" << e->_line << "] " << e->what() << "\n"; e = e->_cause; } return s.str(); } } // namespace aria2