NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
extended-error-message.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_CORE_EXTENDED_ERROR_MESSAGE_HPP
27 #define NFD_CORE_EXTENDED_ERROR_MESSAGE_HPP
28 
29 #include <boost/exception/get_error_info.hpp>
30 
31 namespace nfd {
32 
33 template<typename E>
34 std::string
35 getExtendedErrorMessage(const E& exception)
36 {
37  std::ostringstream errorMessage;
38  errorMessage << exception.what();
39 
40  const char* const* file = boost::get_error_info<boost::throw_file>(exception);
41  const int* line = boost::get_error_info<boost::throw_line>(exception);
42  const char* const* func = boost::get_error_info<boost::throw_function>(exception);
43  if (file && line) {
44  errorMessage << " [from " << *file << ":" << *line;
45  if (func) {
46  errorMessage << " in " << *func;
47  }
48  errorMessage << "]";
49  }
50 
51  return errorMessage.str();
52 }
53 
54 } // namespace nfd
55 
56 #endif // NFD_CORE_EXTENDED_ERROR_MESSAGE_HPP
std::string getExtendedErrorMessage(const E &exception)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40