aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-11-25 08:53:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-11-25 08:53:16 +0200
commit2de154d951d0b89aec8ac9e45e47f5d07947e093 (patch)
tree12346762a9d4662d86964e7f1f7575528386dd7e
parent55e69b274fbdb31f428565a4daff1d4fa510024e (diff)
Get rid of trailing newlines in error messages
-rw-r--r--odb/mysql/error.cxx12
1 files 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);
}
}
}