Ver código fonte

Add extra catch statements

JDierkse 3 anos atrás
pai
commit
d1f313bbf9
1 arquivos alterados com 23 adições e 0 exclusões
  1. 23 0
      MySQL/MySQLClientImpl.cpp

+ 23 - 0
MySQL/MySQLClientImpl.cpp

@@ -95,6 +95,14 @@ void MySQLClientImpl::Execute(const std::string& query)
 		if (errorCode == 2006 || errorCode == 2013)
 			InternalDisconnect();
 	}
+	catch (const std::exception& e)
+	{
+		std::stringstream ss;
+		ss << "MySQLClientImpl::Execute() - Error: " << e.what() << std::endl;
+		ss << "Query: " << query << std::endl;
+		Logging::Log(Logging::Severity::Error, ss.str());
+		InternalDisconnect();
+	}
 }
 
 std::shared_ptr<MySQLResultSetImpl> MySQLClientImpl::ExecuteQuery(const std::string& query)
@@ -127,6 +135,14 @@ std::shared_ptr<MySQLResultSetImpl> MySQLClientImpl::ExecuteQuery(const std::str
 		if (errorCode == 2006 || errorCode == 2013)
 			InternalDisconnect();
 	}
+	catch (const std::exception& e)
+	{
+		std::stringstream ss;
+		ss << "MySQLClientImpl::ExecuteQuery() - Error: " << e.what() << std::endl;
+		ss << "Query: " << query << std::endl;
+		Logging::Log(Logging::Severity::Error, ss.str());
+		InternalDisconnect();
+	}
 
 	return std::make_shared<MySQLResultSetImpl>(nullptr);
 }
@@ -162,6 +178,13 @@ void MySQLClientImpl::InternalConnect()
 		Logging::Log(Logging::Severity::Error, ss.str());
 		InternalDisconnect();
 	}
+	catch (const std::exception& e)
+	{
+		std::stringstream ss;
+		ss << "MySQLClientImpl::Connect() - Error: " << e.what() << std::endl;
+		Logging::Log(Logging::Severity::Error, ss.str());
+		InternalDisconnect();
+	}
 }
 
 void MySQLClientImpl::InternalDisconnect()