Improved error reporting.
This commit is contained in:
parent
b372fb6c6b
commit
56bd304756
4 changed files with 84 additions and 76 deletions
|
|
@ -148,6 +148,7 @@ void ASyncDBConnection::async_query_handler(boost::system::error_code ec, std::s
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// error during consume
|
// error during consume
|
||||||
|
auto error_msg = m_connection.getErrorMessage();
|
||||||
|
|
||||||
}
|
}
|
||||||
//return finished;
|
//return finished;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "Pgsql_Connection.h"
|
#include "Pgsql_Connection.h"
|
||||||
#include "Pgsql_Params.h"
|
#include "Pgsql_Params.h"
|
||||||
#include "Pgsql_Result.h"
|
#include "Pgsql_Result.h"
|
||||||
|
#include "Expected.h"
|
||||||
#include "ConnectionConfig.h"
|
#include "ConnectionConfig.h"
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
@ -29,7 +30,7 @@ public:
|
||||||
Terminating ///< shutting down
|
Terminating ///< shutting down
|
||||||
};
|
};
|
||||||
|
|
||||||
using on_result_callback = std::function<void(std::shared_ptr<Pgsql::Result>, qint64)>;
|
using on_result_callback = std::function<void(Expected<std::shared_ptr<Pgsql::Result>>, qint64)>;
|
||||||
|
|
||||||
explicit ASyncDBConnection(boost::asio::io_service &ios);
|
explicit ASyncDBConnection(boost::asio::io_service &ios);
|
||||||
~ASyncDBConnection();
|
~ASyncDBConnection();
|
||||||
|
|
|
||||||
|
|
@ -205,14 +205,14 @@ void QueryTab::execute()
|
||||||
|
|
||||||
if (m_queryParamListController->empty())
|
if (m_queryParamListController->empty())
|
||||||
m_dbConnection.send(cmd,
|
m_dbConnection.send(cmd,
|
||||||
[this](std::shared_ptr<Pgsql::Result> res, qint64 elapsedms)
|
[this](Expected<std::shared_ptr<Pgsql::Result>> res, qint64 elapsedms)
|
||||||
{
|
{
|
||||||
m_win->QueueTask([this, res, elapsedms]() { query_ready(res, elapsedms); });
|
m_win->QueueTask([this, res, elapsedms]() { query_ready(res, elapsedms); });
|
||||||
});
|
});
|
||||||
else
|
else
|
||||||
m_dbConnection.send(cmd,
|
m_dbConnection.send(cmd,
|
||||||
m_queryParamListController->params(),
|
m_queryParamListController->params(),
|
||||||
[this](std::shared_ptr<Pgsql::Result> res, qint64 elapsedms)
|
[this](Expected<std::shared_ptr<Pgsql::Result>> res, qint64 elapsedms)
|
||||||
{
|
{
|
||||||
m_win->QueueTask([this, res, elapsedms]() { query_ready(res, elapsedms); });
|
m_win->QueueTask([this, res, elapsedms]() { query_ready(res, elapsedms); });
|
||||||
});
|
});
|
||||||
|
|
@ -234,10 +234,11 @@ void QueryTab::explain(bool analyze)
|
||||||
m_stopwatch.start();
|
m_stopwatch.start();
|
||||||
std::string cmd = "EXPLAIN (" + analyze_str + "VERBOSE, BUFFERS, FORMAT JSON) " + getCommand();
|
std::string cmd = "EXPLAIN (" + analyze_str + "VERBOSE, BUFFERS, FORMAT JSON) " + getCommand();
|
||||||
m_dbConnection.send(cmd,
|
m_dbConnection.send(cmd,
|
||||||
[this](std::shared_ptr<Pgsql::Result> res, qint64 )
|
[this](Expected<std::shared_ptr<Pgsql::Result>> exp_res, qint64 )
|
||||||
{
|
{
|
||||||
if (res) {
|
if (exp_res.valid()) {
|
||||||
// Process explain data seperately
|
// Process explain data seperately
|
||||||
|
auto res = exp_res.get();
|
||||||
std::thread([this,res]()
|
std::thread([this,res]()
|
||||||
{
|
{
|
||||||
std::shared_ptr<ExplainRoot> explain;
|
std::shared_ptr<ExplainRoot> explain;
|
||||||
|
|
@ -299,15 +300,14 @@ bool QueryTab::saveSqlTo(const QString &filename)
|
||||||
QString text = ui->queryEdit->toPlainText();
|
QString text = ui->queryEdit->toPlainText();
|
||||||
stream << text;
|
stream << text;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
||||||
QTextDocument *doc = ui->queryEdit->document();
|
QTextDocument *doc = ui->queryEdit->document();
|
||||||
QTextBlock block = doc->firstBlock();
|
QTextBlock block = doc->firstBlock();
|
||||||
while (stream.status() == QTextStream::Ok && block.isValid()) {
|
while (stream.status() == QTextStream::Ok && block.isValid()) {
|
||||||
QString plain = block.text();
|
QString plain = block.text();
|
||||||
stream << plain << "\n";
|
stream << plain << "\n";
|
||||||
block = block.next();
|
block = block.next();
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
stream.flush();
|
stream.flush();
|
||||||
if (stream.status() == QTextStream::Ok) {
|
if (stream.status() == QTextStream::Ok) {
|
||||||
|
|
@ -483,8 +483,10 @@ void QueryTab::setTabCaption(const QString &caption, const QString &tooltip)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryTab::query_ready(std::shared_ptr<Pgsql::Result> dbres, qint64 elapsedms)
|
void QueryTab::query_ready(Expected<std::shared_ptr<Pgsql::Result>> exp_res, qint64 elapsedms)
|
||||||
{
|
{
|
||||||
|
if (exp_res.valid()) {
|
||||||
|
auto dbres = exp_res.get();
|
||||||
if (dbres) {
|
if (dbres) {
|
||||||
addLog("query_ready with result");
|
addLog("query_ready with result");
|
||||||
auto st = dbres->resultStatus();
|
auto st = dbres->resultStatus();
|
||||||
|
|
@ -555,6 +557,10 @@ void QueryTab::query_ready(std::shared_ptr<Pgsql::Result> dbres, qint64 elapsedm
|
||||||
addLog("query_ready with NO result");
|
addLog("query_ready with NO result");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// we have an error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QueryTab::clearResult()
|
void QueryTab::clearResult()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ private:
|
||||||
|
|
||||||
std::string getCommand() const;
|
std::string getCommand() const;
|
||||||
void explain_ready(ExplainRoot::SPtr explain);
|
void explain_ready(ExplainRoot::SPtr explain);
|
||||||
void query_ready(std::shared_ptr<Pgsql::Result> dbres, qint64 elapsedms);
|
void query_ready(Expected<std::shared_ptr<Pgsql::Result>> dbres, qint64 elapsedms);
|
||||||
|
|
||||||
QTabWidget *getTabWidget();
|
QTabWidget *getTabWidget();
|
||||||
void setTabCaption(const QString &caption, const QString &tooltip);
|
void setTabCaption(const QString &caption, const QString &tooltip);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue