Improve error handling

This commit is contained in:
eelke 2022-08-17 18:18:10 +02:00
parent 457b09f15c
commit 80272e81c3
5 changed files with 68 additions and 84 deletions

View file

@ -427,7 +427,7 @@ void ASyncDBConnection::closeConnection()
bool ASyncDBConnection::send(const std::string &command, on_result_callback on_result)
{
if (command.empty())
if (command.empty() || state() == State::NotConnected)
return false;
{
@ -440,7 +440,10 @@ bool ASyncDBConnection::send(const std::string &command, on_result_callback on_r
bool ASyncDBConnection::send(const std::string &command, Pgsql::Params params, on_result_callback on_result)
{
{
if (command.empty() || state() == State::NotConnected)
return false;
{
std::lock_guard<std::mutex> lg(m_threadData->m_commandQueue.m_mutex);
m_threadData->m_commandQueue.m_queue.emplace(command, std::move(params), on_result);
m_threadData->m_commandQueue.m_newEvent.set();