瀏覽代碼

Add extra catch statements

JDierkse 3 年之前
父節點
當前提交
d1f313bbf9
共有 1 個文件被更改,包括 23 次插入0 次删除
  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()