Fix: openening not accessible database crashes program.
OpenDatabase::createOpenDatabase now uses QException derived exception to report failure. This makes it possible to catch the exception in a background thread and rethrow it when the Future is read. Which makes it possible for the database window to properly report the problem.
This commit is contained in:
parent
3820fb2600
commit
ecae0464f9
5 changed files with 36 additions and 24 deletions
|
|
@ -1,22 +1,19 @@
|
|||
#include "OpenDatabase.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include "Pgsql_Connection.h"
|
||||
#include "Pgsql_PgException.h"
|
||||
#include "model/TypeSelectionItemModel.h"
|
||||
|
||||
Expected<OpenDatabase::OpenDatabaseSPtr> OpenDatabase::createOpenDatabase(const ConnectionConfig &cfg)
|
||||
OpenDatabase::OpenDatabaseSPtr OpenDatabase::createOpenDatabase(const ConnectionConfig &cfg)
|
||||
{
|
||||
return Expected<OpenDatabase::OpenDatabaseSPtr>::fromCode(
|
||||
[&cfg] () -> auto {
|
||||
OpenDatabaseSPtr odb(new OpenDatabase(cfg));
|
||||
odb->Init();
|
||||
return odb;
|
||||
});
|
||||
// catch (const PgException &ex) {
|
||||
// return
|
||||
// }
|
||||
|
||||
// return Expected<OpenDatabaseSPtr>::fromException(
|
||||
// std::runtime_error("Failed to get database information"));
|
||||
try {
|
||||
OpenDatabaseSPtr odb(new OpenDatabase(cfg));
|
||||
odb->Init();
|
||||
return odb;
|
||||
}
|
||||
catch (const Pgsql::PgException &ex) {
|
||||
throw OpenDatabaseException(ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
OpenDatabase::OpenDatabase(const ConnectionConfig& cfg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue