Better error reporting of problems during catalog load.

This commit is contained in:
eelke 2017-12-19 18:17:41 +01:00
parent 2a29bed75e
commit c37e9eccb8
2 changed files with 24 additions and 15 deletions

View file

@ -55,6 +55,7 @@ QueryTab *MainWindow::GetActiveQueryTab()
void MainWindow::setConfig(const ConnectionConfig &config) void MainWindow::setConfig(const ConnectionConfig &config)
{ {
m_config = config; m_config = config;
try {
auto res = OpenDatabase::createOpenDatabase(config); auto res = OpenDatabase::createOpenDatabase(config);
if (res.valid()) { if (res.valid()) {
m_database = res.get(); m_database = res.get();
@ -69,6 +70,11 @@ void MainWindow::setConfig(const ConnectionConfig &config)
ui->tabWidget->setCurrentWidget(tt); ui->tabWidget->setCurrentWidget(tt);
newSqlPage(); newSqlPage();
} catch (std::runtime_error &ex) {
QMessageBox msgBox;
msgBox.setText(QString::fromUtf8(ex.what()));
msgBox.exec();
}
} }
void MainWindow::on_actionLoad_SQL_triggered() void MainWindow::on_actionLoad_SQL_triggered()

View file

@ -109,8 +109,11 @@ void load(Pgsql::Connection &conn, IPgContainter &pg_cont)
Pgsql::Result result = conn.query(q.c_str()); Pgsql::Result result = conn.query(q.c_str());
if (result && result.resultStatus() == PGRES_TUPLES_OK) if (result && result.resultStatus() == PGRES_TUPLES_OK)
pg_cont.load(result); pg_cont.load(result);
else else {
throw std::runtime_error("Query failed"); auto details = result.diagDetails();
throw std::runtime_error("Query failed\n" + details.errorMessage);
}
} }