From 2ea245bf58860281437f14f2498bfc8f51f79602 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 16 Mar 2018 12:42:49 -0700 Subject: [PATCH] ircd: Improve bad_lex_cast message with demangled typeid. --- ircd/lexical.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ircd/lexical.cc b/ircd/lexical.cc index 50d80b651..8db0d778d 100644 --- a/ircd/lexical.cc +++ b/ircd/lexical.cc @@ -273,6 +273,7 @@ namespace ircd thread_local char lex_cast_buf[LEX_CAST_BUFS][LEX_CAST_BUFSIZE]; thread_local uint lex_cast_cur; + [[noreturn]] static void throw_bad_lex_cast(const boost::bad_lexical_cast &, const std::type_info &); template static string_view _lex_cast(const T &i, mutable_buffer buf); template static T _lex_cast(const string_view &s); } @@ -301,7 +302,7 @@ try } catch(const boost::bad_lexical_cast &e) { - throw ircd::bad_lex_cast("%s", e.what()); + throw_bad_lex_cast(e, typeid(T)); } /// Internal template providing conversions from a string to a number; @@ -315,7 +316,17 @@ try } catch(const boost::bad_lexical_cast &e) { - throw ircd::bad_lex_cast("%s", e.what()); + throw_bad_lex_cast(e, typeid(T)); +} + +void +ircd::throw_bad_lex_cast(const boost::bad_lexical_cast &e, + const std::type_info &t) +{ + throw ircd::bad_lex_cast + { + "%s: %s", e.what(), demangle(t.name()) + }; } template<> ircd::string_view