Skip to content

Commit

Permalink
Fixed #578: Use angle brackets in HPX error dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Oct 20, 2012
1 parent c4057ba commit 8fbc23f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
36 changes: 18 additions & 18 deletions examples/quickstart/error_handling.cpp
Expand Up @@ -51,15 +51,15 @@ int hpx_main()
}
catch (hpx::exception const& e) {
// Print the elements of the diagnostic information separately
hpx::cout << "[locality-id]: " << hpx::get_locality_id(e) << "\n";
hpx::cout << "[hostname]: " << hpx::get_host_name(e) << "\n";
hpx::cout << "[pid]: " << hpx::get_process_id(e) << "\n";
hpx::cout << "[function]: " << hpx::get_function_name(e) << "\n";
hpx::cout << "[file]: " << hpx::get_file_name(e) << "\n";
hpx::cout << "[line]: " << hpx::get_line_number(e) << "\n";
hpx::cout << "[os-thread]: " << hpx::get_os_thread(e) << "\n";
hpx::cout << "[thread-id]: " << std::hex << hpx::get_thread_id(e) << "\n";
hpx::cout << "[thread-description]: "
hpx::cout << "{locality-id}: " << hpx::get_locality_id(e) << "\n";
hpx::cout << "{hostname}: " << hpx::get_host_name(e) << "\n";
hpx::cout << "{pid}: " << hpx::get_process_id(e) << "\n";
hpx::cout << "{function}: " << hpx::get_function_name(e) << "\n";
hpx::cout << "{file}: " << hpx::get_file_name(e) << "\n";
hpx::cout << "{line}: " << hpx::get_line_number(e) << "\n";
hpx::cout << "{os-thread}: " << hpx::get_os_thread(e) << "\n";
hpx::cout << "{thread-id}: " << std::hex << hpx::get_thread_id(e) << "\n";
hpx::cout << "{thread-description}: "
<< hpx::get_thread_description(e) << "\n";
}
hpx::cout << hpx::flush;
Expand Down Expand Up @@ -110,15 +110,15 @@ int hpx_main()

// Print the elements of the diagnostic information separately
if (ec) {
hpx::cout << "[locality-id]: " << hpx::get_locality_id(ec) << "\n";
hpx::cout << "[hostname]: " << hpx::get_host_name(ec) << "\n";
hpx::cout << "[pid]: " << hpx::get_process_id(ec) << "\n";
hpx::cout << "[function]: " << hpx::get_function_name(ec) << "\n";
hpx::cout << "[file]: " << hpx::get_file_name(ec) << "\n";
hpx::cout << "[line]: " << hpx::get_line_number(ec) << "\n";
hpx::cout << "[os-thread]: " << hpx::get_os_thread(ec) << "\n";
hpx::cout << "[thread-id]: " << std::hex << hpx::get_thread_id(ec) << "\n";
hpx::cout << "[thread-description]: "
hpx::cout << "{locality-id}: " << hpx::get_locality_id(ec) << "\n";
hpx::cout << "{hostname}: " << hpx::get_host_name(ec) << "\n";
hpx::cout << "{pid}: " << hpx::get_process_id(ec) << "\n";
hpx::cout << "{function}: " << hpx::get_function_name(ec) << "\n";
hpx::cout << "{file}: " << hpx::get_file_name(ec) << "\n";
hpx::cout << "{line}: " << hpx::get_line_number(ec) << "\n";
hpx::cout << "{os-thread}: " << hpx::get_os_thread(ec) << "\n";
hpx::cout << "{thread-id}: " << std::hex << hpx::get_thread_id(ec) << "\n";
hpx::cout << "{thread-description}: "
<< hpx::get_thread_description(ec) << "\n\n";
}

Expand Down
30 changes: 15 additions & 15 deletions src/exception.cpp
Expand Up @@ -254,7 +254,7 @@ namespace hpx { namespace detail
// so that the program doesn't abort without any diagnostics.
if (!threw) {
std::cerr << "Runtime is not available, reporting error locally\n"
"[what]: " << str << std::endl;
"{what}: " << str << std::endl;
}
std::abort();
}
Expand Down Expand Up @@ -289,78 +289,78 @@ namespace hpx
boost::get_error_info<hpx::detail::throw_stacktrace>(e);
if (back_trace && !back_trace->empty()) {
// FIXME: add indentation to stack frame information
strm << "[stack-trace]: " << *back_trace << "\n";
strm << "{stack-trace}: " << *back_trace << "\n";
}

std::string const* env =
boost::get_error_info<hpx::detail::throw_env>(e);
if (env && !env->empty())
strm << "[env]: " << *env;
strm << "{env}: " << *env;

// Try a cast to std::exception - this should handle boost.system
// error codes in addition to the standard library exceptions.
std::exception const* se = dynamic_cast<std::exception const*>(&e);
if (se)
strm << "[what]: " << se->what() << "\n";
strm << "{what}: " << se->what() << "\n";

boost::uint32_t const* locality =
boost::get_error_info<hpx::detail::throw_locality>(e);
if (locality)
strm << "[locality-id]: " << *locality << "\n";
strm << "{locality-id}: " << *locality << "\n";

std::string const* hostname_ =
boost::get_error_info<hpx::detail::throw_hostname>(e);
if (hostname_ && !hostname_->empty())
strm << "[hostname]: " << *hostname_ << "\n";
strm << "{hostname}: " << *hostname_ << "\n";

boost::int64_t const* pid_ =
boost::get_error_info<hpx::detail::throw_pid>(e);
if (pid_ && -1 != *pid_)
strm << "[process-id]: " << *pid_ << "\n";
strm << "{process-id}: " << *pid_ << "\n";

char const* const* func =
boost::get_error_info<boost::throw_function>(e);
if (func) {
strm << "[function]: " << *func << "\n";
strm << "{function}: " << *func << "\n";
}
else {
std::string const* s =
boost::get_error_info<hpx::detail::throw_function>(e);
if (s)
strm << "[function]: " << *s << "\n";
strm << "{function}: " << *s << "\n";
}

char const* const* file =
boost::get_error_info<boost::throw_file>(e);
if (file) {
strm << "[file]: " << *file << "\n";
strm << "{file}: " << *file << "\n";
}
else {
std::string const* s =
boost::get_error_info<hpx::detail::throw_file>(e);
if (s)
strm << "[file]: " << *s << "\n";
strm << "{file}: " << *s << "\n";
}

int const* line =
boost::get_error_info<boost::throw_line>(e);
if (line)
strm << "[line]: " << *line << "\n";
strm << "{line}: " << *line << "\n";

std::size_t const* shepherd =
boost::get_error_info<hpx::detail::throw_shepherd>(e);
if (shepherd && std::size_t(-1) != *shepherd)
strm << "[os-thread]: " << *shepherd << "\n";
strm << "{os-thread}: " << *shepherd << "\n";

std::size_t const* thread_id =
boost::get_error_info<hpx::detail::throw_thread_id>(e);
if (thread_id && *thread_id)
strm << (boost::format("[thread-id]: %016x\n") % *thread_id);
strm << (boost::format("{thread-id}: %016x\n") % *thread_id);

std::string const* thread_description =
boost::get_error_info<hpx::detail::throw_thread_name>(e);
if (thread_description && !thread_description->empty())
strm << "[thread-description]: " << *thread_description << "\n";
strm << "{thread-description}: " << *thread_description << "\n";

// add full build information
strm << full_build_string();
Expand Down
8 changes: 4 additions & 4 deletions src/runtime.cpp
Expand Up @@ -49,9 +49,9 @@ namespace hpx
{
std::cerr
#if defined(HPX_HAVE_STACKTRACES)
<< "[stack-trace]: " << hpx::detail::backtrace() << "\n"
<< "{stack-trace}: " << hpx::detail::backtrace() << "\n"
#endif
<< "[what]: " << (reason ? reason : "Unknown reason") << "\n"
<< "{what}: " << (reason ? reason : "Unknown reason") << "\n"
<< full_build_string(); // add full build information

std::abort();
Expand Down Expand Up @@ -100,9 +100,9 @@ namespace hpx
char* reason = strsignal(signum);
std::cerr
#if defined(HPX_HAVE_STACKTRACES)
<< "[stack-trace]: " << hpx::detail::backtrace() << "\n"
<< "{stack-trace}: " << hpx::detail::backtrace() << "\n"
#endif
<< "[what]: " << (reason ? reason : "Unknown signal") << "\n"
<< "{what}: " << (reason ? reason : "Unknown signal") << "\n"
<< full_build_string(); // add full build information

std::abort();
Expand Down
14 changes: 7 additions & 7 deletions src/version.cpp
Expand Up @@ -64,13 +64,13 @@ namespace hpx
std::string full_build_string()
{
hpx::util::osstream strm;
strm << "[version]: " << build_string() << "\n"
<< "[boost]: " << boost_version() << "\n"
<< "[build-type]: " << build_type() << "\n"
<< "[date]: " << build_date_time() << "\n"
<< "[platform]: " << boost_platform() << "\n"
<< "[compiler]: " << boost_compiler() << "\n"
<< "[stdlib]: " << boost_stdlib() << "\n";
strm << "{version}: " << build_string() << "\n"
<< "{boost}: " << boost_version() << "\n"
<< "{build-type}: " << build_type() << "\n"
<< "{date}: " << build_date_time() << "\n"
<< "{platform}: " << boost_platform() << "\n"
<< "{compiler}: " << boost_compiler() << "\n"
<< "{stdlib}: " << boost_stdlib() << "\n";
return util::osstream_get_string(strm);
}

Expand Down

0 comments on commit 8fbc23f

Please sign in to comment.