Commit 307bec1a authored by Dominik Charousset's avatar Dominik Charousset

Do not throw exceptions in `to_string`

parent 20c5b7d4
...@@ -131,7 +131,8 @@ class tuple_vals : public message_data { ...@@ -131,7 +131,8 @@ class tuple_vals : public message_data {
if (et.first != 0) { if (et.first != 0) {
return numbered_type_names[et.first - 1]; return numbered_type_names[et.first - 1];
} }
return uniform_typeid(*et.second)->name(); auto uti = uniform_typeid(*et.second, true);
return uti ? uti->name() : "-invalid-";
} }
uint16_t type_nr_at(size_t pos) const override { uint16_t type_nr_at(size_t pos) const override {
......
...@@ -513,9 +513,14 @@ namespace detail { ...@@ -513,9 +513,14 @@ namespace detail {
string to_string_impl(const void* what, const uniform_type_info* utype) { string to_string_impl(const void* what, const uniform_type_info* utype) {
std::ostringstream osstr; std::ostringstream osstr;
string_serializer strs(osstr); string_serializer strs(osstr);
try {
strs.begin_object(utype); strs.begin_object(utype);
utype->serialize(what, &strs); utype->serialize(what, &strs);
strs.end_object(); strs.end_object();
}
catch (std::runtime_error&) {
return "---not-serializable---";
}
return osstr.str(); return osstr.str();
} }
......
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