Unverified Commit 264d14b6 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #1021

Improve to_string output for caf::error
parents 55be26f8 333c5256
...@@ -402,7 +402,8 @@ timespan actor_system_config::stream_tick_duration() const noexcept { ...@@ -402,7 +402,8 @@ timespan actor_system_config::stream_tick_duration() const noexcept {
return timespan{ns_count}; return timespan{ns_count};
} }
std::string actor_system_config::render(const error& err) { std::string actor_system_config::render(const error& err) {
std::string msg; if (!err)
return "none";
switch (static_cast<uint64_t>(err.category())) { switch (static_cast<uint64_t>(err.category())) {
case atom_uint("system"): case atom_uint("system"):
return render_sec(err.code(), err.category(), err.context()); return render_sec(err.code(), err.category(), err.context());
...@@ -410,8 +411,11 @@ std::string actor_system_config::render(const error& err) { ...@@ -410,8 +411,11 @@ std::string actor_system_config::render(const error& err) {
return render_exit_reason(err.code(), err.category(), err.context()); return render_exit_reason(err.code(), err.category(), err.context());
case atom_uint("parser"): case atom_uint("parser"):
return render_pec(err.code(), err.category(), err.context()); return render_pec(err.code(), err.category(), err.context());
default:
return deep_to_string(meta::type_name("error"), err.code(),
err.category(), meta::omittable_if_empty(),
err.context());
} }
return "unknown-error";
} }
std::string std::string
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "caf/error.hpp" #include "caf/error.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/config.hpp" #include "caf/config.hpp"
#include "caf/deep_to_string.hpp" #include "caf/deep_to_string.hpp"
#include "caf/deserializer.hpp" #include "caf/deserializer.hpp"
...@@ -169,10 +170,7 @@ void error::init() { ...@@ -169,10 +170,7 @@ void error::init() {
} }
std::string to_string(const error& x) { std::string to_string(const error& x) {
if (!x) return actor_system_config::render(x);
return "none";
return deep_to_string(meta::type_name("error"), x.code(), x.category(),
meta::omittable_if_empty(), x.context());
} }
} // namespace caf } // namespace caf
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment