Better error reporting of problems during catalog load.
This commit is contained in:
parent
2a29bed75e
commit
c37e9eccb8
2 changed files with 24 additions and 15 deletions
|
|
@ -55,20 +55,26 @@ QueryTab *MainWindow::GetActiveQueryTab()
|
|||
void MainWindow::setConfig(const ConnectionConfig &config)
|
||||
{
|
||||
m_config = config;
|
||||
auto res = OpenDatabase::createOpenDatabase(config);
|
||||
if (res.valid()) {
|
||||
m_database = res.get();
|
||||
try {
|
||||
auto res = OpenDatabase::createOpenDatabase(config);
|
||||
if (res.valid()) {
|
||||
m_database = res.get();
|
||||
}
|
||||
QString title = "pglab - ";
|
||||
title += m_config.name().c_str();
|
||||
setWindowTitle(title);
|
||||
|
||||
auto tt = new TablesPage(this);
|
||||
tt->setCatalog(m_database->catalogue());
|
||||
ui->tabWidget->addTab(tt, "Tables");
|
||||
ui->tabWidget->setCurrentWidget(tt);
|
||||
|
||||
newSqlPage();
|
||||
} catch (std::runtime_error &ex) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromUtf8(ex.what()));
|
||||
msgBox.exec();
|
||||
}
|
||||
QString title = "pglab - ";
|
||||
title += m_config.name().c_str();
|
||||
setWindowTitle(title);
|
||||
|
||||
auto tt = new TablesPage(this);
|
||||
tt->setCatalog(m_database->catalogue());
|
||||
ui->tabWidget->addTab(tt, "Tables");
|
||||
ui->tabWidget->setCurrentWidget(tt);
|
||||
|
||||
newSqlPage();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionLoad_SQL_triggered()
|
||||
|
|
|
|||
|
|
@ -109,8 +109,11 @@ void load(Pgsql::Connection &conn, IPgContainter &pg_cont)
|
|||
Pgsql::Result result = conn.query(q.c_str());
|
||||
if (result && result.resultStatus() == PGRES_TUPLES_OK)
|
||||
pg_cont.load(result);
|
||||
else
|
||||
throw std::runtime_error("Query failed");
|
||||
else {
|
||||
auto details = result.diagDetails();
|
||||
|
||||
throw std::runtime_error("Query failed\n" + details.errorMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue