// excerpts from http://code.google.com/p/muduo/ // // Use of this source code is governed by a BSD-style license // that can be found in the License file. // // Author: Shuo Chen (giantchen at gmail dot com) #include "Exception.h" #include #include #include using namespace muduo; Exception::Exception(const char* what) : message_(what) { const int len = 200; void* buffer[len]; int nptrs = ::backtrace(buffer, len); char** strings = ::backtrace_symbols(buffer, nptrs); if (strings) { for (int i = 0; i < nptrs; ++i) { // TODO demangle funcion name with abi::__cxa_demangle stack_.append(strings[i]); stack_.push_back('\n'); } free(strings); } } Exception::~Exception() throw () { } const char* Exception::what() const throw() { return message_.c_str(); } const char* Exception::stackTrace() const throw() { return stack_.c_str(); }