[glom/sqlbuilder2] DbUtils: Catch SqlError exception.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/sqlbuilder2] DbUtils: Catch SqlError exception.
- Date: Fri, 14 May 2010 07:32:27 +0000 (UTC)
commit 62954eb206c61e12057d58931a0c408060bb58e6
Author: Murray Cumming <murrayc murrayc com>
Date: Thu May 13 22:40:34 2010 +0200
DbUtils: Catch SqlError exception.
* glom/libglom/db_utils.cc: query_execute_select(), query_execute_select(),
sqlbuilder_get_full_query(): Catch SqlError too, as this seems to be
thrown too.
ChangeLog | 7 +++++++
glom/libglom/db_utils.cc | 39 ++++++++++++++++++++++++++-------------
glom/libglom/utils.cc | 16 ++++++++++++----
3 files changed, 45 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2e9190a..d048fbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-05-13 Murray Cumming <murrayc murrayc com>
+ DbUtils: Catch SqlError exception.
+
+ * glom/libglom/db_utils.cc: query_execute_select(), query_execute_select():
+ Catch SqlError too, as this seems to be thrown too.
+
+2010-05-13 Murray Cumming <murrayc murrayc com>
+
DbUtils::query_execute(): Remove params parameter.
* glom/libglom/db_utils.[h|cc]: query_execute(): Remove the unused params
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 4160c40..76309d0 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -1560,9 +1560,13 @@ Glib::RefPtr<Gnome::Gda::DataModel> query_execute_select(const Glib::RefPtr<cons
{
std::cerr << "debug: query_execute_select(): ServerProviderError: exception from statement_execute_select_builder(): code=" << ex.code() << "message=" << ex.what() << std::endl;
}
+ catch(const Gnome::Gda::SqlError& ex) //TODO: Make sure that statement_execute_select_builder() is documented as throwing this.
+ {
+ std::cerr << "debug: query_execute_select(): SqlError: exception from statement_execute_select_builder(): " << ex.what() << std::endl;
+ }
catch(const Glib::Error& ex)
{
- std::cerr << "debug: query_execute_select(): Error: exception from statement_execute_select_builder(): " << ex.what() << std::endl;
+ std::cerr << "debug: query_execute_select(): Error (" << typeid(ex).name() << "): exception from statement_execute_select_builder(): " << ex.what() << std::endl;
}
#else
@@ -1651,16 +1655,6 @@ bool query_execute_string(const Glib::ustring& strQuery, const Glib::RefPtr<Gnom
std::cerr << " full_query: " << full_query << std::endl;
return false;
}
-#else
- std::auto_ptr<Glib::Error> exec_error;
- exec_retval = gda_connection->statement_execute_non_select (stmt, params, exec_error);
- if(exec_error.get())
- {
- std::cerr << "DbUtils::query_execute: ConnectionError: " << exec_error->what() << std::endl;
- const Glib::ustring full_query = stmt->to_sql(params, exec_error);
- std::cerr << " full_query: " << full_query << std::endl;
- return false;
- }
#endif
return (exec_retval >= 0);
}
@@ -1688,13 +1682,32 @@ bool query_execute(const Glib::RefPtr<const Gnome::Gda::SqlBuilder>& builder)
{
exec_retval = gda_connection->statement_execute_non_select_builder(builder);
}
- catch(const Glib::Error& error)
+ catch(const Gnome::Gda::ConnectionError& ex)
{
- std::cerr << "DbUtils::query_execute: ConnectionError: " << error.what() << std::endl;
+ std::cerr << "debug: query_execute_select(): ConnectionError: exception from statement_execute_non_select_builder(): " << ex.what() << std::endl;
+ const std::string full_query = Utils::sqlbuilder_get_full_query(builder);
+ std::cerr << " full_query: " << full_query << std::endl;
+ return false;
+ }
+ catch(const Gnome::Gda::ServerProviderError& ex)
+ {
+ std::cerr << "debug: query_execute_select(): ServerProviderError: exception from statement_execute_non_select_builder(): code=" << ex.code() << "message=" << ex.what() << std::endl;
+ const std::string full_query = Utils::sqlbuilder_get_full_query(builder);
+ std::cerr << " full_query: " << full_query << std::endl;
+ return false;
+ }
+ catch(const Gnome::Gda::SqlError& ex) //TODO: Make sure that statement_execute_select_builder() is documented as throwing this.
+ {
+ std::cerr << "debug: query_execute_select(): SqlError: exception from statement_execute_non_select_builder(): " << ex.what() << std::endl;
const std::string full_query = Utils::sqlbuilder_get_full_query(builder);
std::cerr << " full_query: " << full_query << std::endl;
return false;
}
+ catch(const Glib::Error& ex)
+ {
+ std::cerr << "debug: query_execute_select(): Error (" << typeid(ex).name() << "): exception from statement_execute_non_select_builder(): " << ex.what() << std::endl;
+ return false;
+ }
#else
std::auto_ptr<Glib::Error> exec_error;
exec_retval = gda_connection->statement_execute_non_select_builder(builder, exec_error);
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index c10c26b..0208502 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -930,13 +930,17 @@ std::string Utils::sqlbuilder_get_full_query(
if(stmt)
result = stmt->to_sql(params);
}
+ catch(const Gnome::Gda::SqlError& ex)
+ {
+ std::cerr << "sqlbuilder_get_full_query(): SqlError exception while getting query: " << ex.what() << std::endl;
+ }
catch(const Glib::Exception& ex)
{
- std::cerr << "sqlbuilder_get_full_query(): exception while getting query: " << ex.what() << std::endl;
+ std::cerr << "sqlbuilder_get_full_query(): exception (" << typeid(ex).name() << ") while getting query: " << ex.what() << std::endl;
}
catch(const std::exception& ex)
{
- std::cerr << "sqlbuilder_get_full_query(): exception while getting query: " << ex.what() << std::endl;
+ std::cerr << "sqlbuilder_get_full_query(): exception (" << typeid(ex).name() << ") while getting query: " << ex.what() << std::endl;
}
//Convert to something that std::cout should be able to handle.
@@ -959,13 +963,17 @@ std::string Utils::sqlbuilder_get_full_query(
if(stmt)
result = stmt->to_sql();
}
+ catch(const Gnome::Gda::SqlError& ex)
+ {
+ std::cerr << "sqlbuilder_get_full_query(): SqlError exception while getting query: " << ex.what() << std::endl;
+ }
catch(const Glib::Exception& ex)
{
- std::cerr << "sqlbuilder_get_full_query(): exception while getting query: " << ex.what() << std::endl;
+ std::cerr << "sqlbuilder_get_full_query(): exception (" << typeid(ex).name() << ") while getting query: " << ex.what() << std::endl;
}
catch(const std::exception& ex)
{
- std::cerr << "sqlbuilder_get_full_query(): exception while getting query: " << ex.what() << std::endl;
+ std::cerr << "sqlbuilder_get_full_query(): exception (" << typeid(ex).name() << ") while getting query: " << ex.what() << std::endl;
}
//Convert to something that std::cout should be able to handle.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]