/* */ #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