diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-11-25 08:53:16 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-11-25 08:53:16 +0200 |
commit | 2de154d951d0b89aec8ac9e45e47f5d07947e093 (patch) | |
tree | 12346762a9d4662d86964e7f1f7575528386dd7e | |
parent | 55e69b274fbdb31f428565a4daff1d4fa510024e (diff) |
Get rid of trailing newlines in error messages
-rw-r--r-- | odb/mysql/error.cxx | 12 |
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); } } } |