From 2de154d951d0b89aec8ac9e45e47f5d07947e093 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 25 Nov 2014 08:53:16 +0200 Subject: Get rid of trailing newlines in error messages --- odb/mysql/error.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/odb/mysql/error.cxx b/odb/mysql/error.cxx index b439d23..81990ad 100644 --- a/odb/mysql/error.cxx +++ b/odb/mysql/error.cxx @@ -15,11 +15,11 @@ namespace odb { namespace mysql { - void + static void translate_error (connection& c, unsigned int e, const string& sqlstate, - const string& message) + string msg) { switch (e) { @@ -44,7 +44,13 @@ namespace odb } default: { - throw database_exception (e, sqlstate, message); + // Get rid of a trailing newline if there is one. + // + string::size_type n (msg.size ()); + if (n != 0 && msg[n - 1] == '\n') + msg.resize (n - 1); + + throw database_exception (e, sqlstate, msg); } } } -- cgit v1.1