[glom] PostgreSQL: Print stderr message when the connection fails completely.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] PostgreSQL: Print stderr message when the connection fails completely.
- Date: Mon, 19 Dec 2011 14:10:07 +0000 (UTC)
commit 4f351903032bcf6431eb1908b5771f68c9b1f468
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Dec 18 23:34:02 2011 +0100
PostgreSQL: Print stderr message when the connection fails completely.
* glom/libglom/connectionpool_backends/postgres.cc: This can provide
a clue, for instance when the hostname cannot be resolved.
ChangeLog | 7 +++++++
glom/libglom/connectionpool_backends/postgres.cc | 7 +++++--
2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3e793e5..5c479d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2011-12-18 Murray Cumming <murrayc murrayc com>
+ PostgreSQL: Print stderr message when the connection fails completely.
+
+ * glom/libglom/connectionpool_backends/postgres.cc: This can provide
+ a clue, for instance when the hostname cannot be resolved.
+
+2011-12-18 Murray Cumming <murrayc murrayc com>
+
Add the glom_test_connection command-line tool.
* Makefile_libglom.am:
diff --git a/glom/libglom/connectionpool_backends/postgres.cc b/glom/libglom/connectionpool_backends/postgres.cc
index 1bda810..9d3bce2 100644
--- a/glom/libglom/connectionpool_backends/postgres.cc
+++ b/glom/libglom/connectionpool_backends/postgres.cc
@@ -106,7 +106,7 @@ Glib::RefPtr<Gnome::Gda::Connection> Postgres::attempt_connect(const Glib::ustri
catch(const Glib::Error& ex)
{
#ifdef GLOM_CONNECTION_DEBUG
- std::cout << "debug: " << G_STRFUNC << ": Attempt to connect to database failed on port=" << port << ", database=" << database << ": " << ex.what() << std::endl;
+ std::cout << "debug: " << G_STRFUNC << ": Attempt to connect to database failed on port=" << port << ", database=" << database << ": " << "error code=" << ex.code() << ", error message: " << ex.what() << std::endl;
std::cout << "debug: " << G_STRFUNC << ": Attempting to connect without specifying the database." << std::endl;
#endif
@@ -120,7 +120,10 @@ Glib::RefPtr<Gnome::Gda::Connection> Postgres::attempt_connect(const Glib::ustri
Gnome::Gda::CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE);
}
catch(const Glib::Error& ex)
- {}
+ {
+ //Show this on stderr because it can contain useful clues such as a hostname that cannot be resolved.
+ std::cerr << G_STRFUNC << ": Attempt to connect to default database failed on port=" << port << " : " << "error code=" << ex.code() << ", error message: " << ex.what() << std::endl;
+ }
#ifdef GLOM_CONNECTION_DEBUG
if(temp_conn)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]