improved exception handling: diagnostics of URL connection error v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon, 01 Jun 2020 17:23:27 +0200
branchv_0
changeset 41 4b2d46989f44
parent 40 0d67e271abb7
child 42 7f668a5a435b
improved exception handling: diagnostics of URL connection error
src/DriverManager.cpp
--- a/src/DriverManager.cpp	Mon Jun 01 17:22:13 2020 +0200
+++ b/src/DriverManager.cpp	Mon Jun 01 17:23:27 2020 +0200
@@ -79,10 +79,7 @@
 			(SQLCHAR*) convertor.to_bytes(connectionString).c_str(), SQL_NTS,
 			(SQLCHAR*) completeConnectionString, sizeof (completeConnectionString), &completeConnectionStringLength,
 			SQL_DRIVER_NOPROMPT);
-	if (OdbcCommon::isNotSuccessful(result)) {
-		OdbcCommon::freeHandle(SQL_HANDLE_DBC, connection);
-		throw SqlException(L"Unable to connect to URL: " + connectionString, result, SQL_HANDLE_ENV, environment);
-	}
+	if (OdbcCommon::isNotSuccessful(result)) throw SqlException(L"Unable to connect to URL: " + connectionString, result, SQL_HANDLE_DBC, connection, true);
 	return new Connection(connection);
 }