From cd0aca758e7d735e1bfdaa01298470be044de06b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 20 Oct 2018 15:22:25 +0100 Subject: Demangle typenames in column conversion exception --- libdbpp/column.cpp | 12 +++++++++++- libdbpp/error.h | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libdbpp/column.cpp b/libdbpp/column.cpp index 2028f03..c630430 100644 --- a/libdbpp/column.cpp +++ b/libdbpp/column.cpp @@ -1,6 +1,8 @@ #include "column.h" #include #include +#include +#include namespace DB { Column::Column(const Glib::ustring & n, unsigned int i) : @@ -13,7 +15,15 @@ Column::~Column() { } -InvalidConversion::InvalidConversion(const char * const f, const char * const t) : from(f), to(t) { } +static +std::string +demangle(const char * const mangled) +{ + std::unique_ptr r(abi::__cxa_demangle(mangled, NULL, NULL, NULL), &free); + return &*r; +}; + +InvalidConversion::InvalidConversion(const char * const f, const char * const t) : from(demangle(f)), to(demangle(t)) { } AdHocFormatter(InvalidConversionMsg, "Invalid conversion from column type (%?) to value type (%?)"); std::string diff --git a/libdbpp/error.h b/libdbpp/error.h index bcb641d..99a28cb 100644 --- a/libdbpp/error.h +++ b/libdbpp/error.h @@ -32,8 +32,8 @@ namespace DB { private: std::string message() const throw() override; - const char * from; - const char * to; + const std::string from; + const std::string to; }; class DLL_PUBLIC UnexpectedNullValue : public AdHoc::Exception { -- cgit v1.2.3