summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-10-20 15:22:25 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2018-10-20 15:22:25 +0100
commitcd0aca758e7d735e1bfdaa01298470be044de06b (patch)
tree82cce7e8d8ebcaf5e1aa061223d95df210e3e1b0
parentFully templated extractor (diff)
downloadlibdbpp-cd0aca758e7d735e1bfdaa01298470be044de06b.tar.bz2
libdbpp-cd0aca758e7d735e1bfdaa01298470be044de06b.tar.xz
libdbpp-cd0aca758e7d735e1bfdaa01298470be044de06b.zip
Demangle typenames in column conversion exception
-rw-r--r--libdbpp/column.cpp12
-rw-r--r--libdbpp/error.h4
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 <exception>
#include <compileTimeFormatter.h>
+#include <memory>
+#include <cxxabi.h>
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<char, decltype(&free)> 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<Error> {