Commit 2fd22c72 authored by Dominik Charousset's avatar Dominik Charousset

Make default render functions public

parent b9e7115d
...@@ -316,6 +316,16 @@ public: ...@@ -316,6 +316,16 @@ public:
int (*slave_mode_fun)(actor_system&, const actor_system_config&); int (*slave_mode_fun)(actor_system&, const actor_system_config&);
// -- default error rendering functions --------------------------------------
static std::string render(const error& err);
static std::string render_sec(uint8_t, atom_value, const message&);
static std::string render_exit_reason(uint8_t, atom_value, const message&);
static std::string render_pec(uint8_t, atom_value, const message&);
protected: protected:
virtual std::string make_help_text(const std::vector<message::cli_arg>&); virtual std::string make_help_text(const std::vector<message::cli_arg>&);
...@@ -332,12 +342,6 @@ private: ...@@ -332,12 +342,6 @@ private:
actor_system_config& set_impl(string_view name, config_value value); actor_system_config& set_impl(string_view name, config_value value);
static std::string render_sec(uint8_t, atom_value, const message&);
static std::string render_exit_reason(uint8_t, atom_value, const message&);
static std::string render_pec(uint8_t, atom_value, const message&);
void extract_config_file_path(string_list& args); void extract_config_file_path(string_list& args);
}; };
......
...@@ -318,6 +318,18 @@ timespan actor_system_config::stream_tick_duration() const noexcept { ...@@ -318,6 +318,18 @@ timespan actor_system_config::stream_tick_duration() const noexcept {
stream_max_batch_delay.count()); stream_max_batch_delay.count());
return timespan{ns_count}; return timespan{ns_count};
} }
std::string actor_system_config::render(const error& err) {
std::string msg;
switch (static_cast<uint64_t>(err.category())) {
case atom_uint("system"):
return render_sec(err.code(), err.category(), err.context());
case atom_uint("exit"):
return render_exit_reason(err.code(), err.category(), err.context());
case atom_uint("parser"):
return render_pec(err.code(), err.category(), err.context());
}
return "unknown-error";
}
std::string actor_system_config::render_sec(uint8_t x, atom_value, std::string actor_system_config::render_sec(uint8_t x, atom_value,
const message& xs) { const message& xs) {
...@@ -335,7 +347,7 @@ std::string actor_system_config::render_exit_reason(uint8_t x, atom_value, ...@@ -335,7 +347,7 @@ std::string actor_system_config::render_exit_reason(uint8_t x, atom_value,
std::string actor_system_config::render_pec(uint8_t x, atom_value, std::string actor_system_config::render_pec(uint8_t x, atom_value,
const message& xs) { const message& xs) {
auto tmp = static_cast<exit_reason>(x); auto tmp = static_cast<pec>(x);
return deep_to_string(meta::type_name("parser_error"), tmp, return deep_to_string(meta::type_name("parser_error"), tmp,
meta::omittable_if_empty(), xs); meta::omittable_if_empty(), xs);
} }
......
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