diff --git a/pglab/MainWindow.cpp b/pglab/MainWindow.cpp index 360a3c5..0d5cde6 100644 --- a/pglab/MainWindow.cpp +++ b/pglab/MainWindow.cpp @@ -154,8 +154,8 @@ void MainWindow::on_actionAbout_triggered() QMessageBox::about(this, "pgLab 0.1", tr( "Copyrights 2016-2017, Eelke Klein, All Rights Reserved.\n" "\n" - "The program is provided AS IS with NO WARRANTY OF ANY KIND," - " INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS " + "The program is provided AS IS with NO WARRANTY OF ANY KIND, " + "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS " "FOR A PARTICULAR PURPOSE.\n" "\n" "This program is dynamically linked with Qt 5.9 Copyright (C) 2017 " @@ -278,7 +278,6 @@ void MainWindow::on_actionCopy_triggered() method.invoke(w, Qt::AutoConnection); } } - //this->ui-> } diff --git a/pglab/PgDatabaseCatalog.cpp b/pglab/PgDatabaseCatalog.cpp index 7703423..0784af5 100644 --- a/pglab/PgDatabaseCatalog.cpp +++ b/pglab/PgDatabaseCatalog.cpp @@ -149,7 +149,7 @@ void PgDatabaseCatalog::loadInfo(Pgsql::Connection &conn) void load(Pgsql::Connection &conn, IPgContainter &pg_cont) { - QThread::msleep(400); + //QThread::msleep(400); std::string q = pg_cont.getLoadQuery(); Pgsql::Result result = conn.query(q.c_str()); if (result && result.resultStatus() == PGRES_TUPLES_OK) diff --git a/pgsql/Pgsql_PgException.h b/pgsql/Pgsql_PgException.h index eba2945..e8a8f9f 100644 --- a/pgsql/Pgsql_PgException.h +++ b/pgsql/Pgsql_PgException.h @@ -1,23 +1,52 @@ -#ifndef PGEXCEPTION_H +#ifndef PGEXCEPTION_H #define PGEXCEPTION_H +#include #include #include namespace Pgsql { - class PgException { + class ResultCode { + public: + explicit ResultCode(std::string result_code) + : m_resultCode(std::move(result_code)) + { + assert(m_resultCode.length() == 5); + } + + std::string getClass() const + { + return m_resultCode.substr(1,2); + } + + /** Helper to easily check the class of the error + * + */ + bool isClass(const std::string_view cls) + { + return m_resultCode.compare(1, 2, cls); + } + + const std::string& getSpecific() const + { + return m_resultCode; + } + private: + std::string m_resultCode; + }; + + class PgException: public std::runtime_error { public: PgException(const char *msg) - : message(msg) + : std::runtime_error(msg) {} PgException(std::string msg) - : message(std::move(msg)) - {} + : std::runtime_error(msg) + {} private: - std::string message; }; @@ -25,14 +54,21 @@ namespace Pgsql { public: PgResultError(std::string msg, std::string result_code) : PgException(std::move(msg)) + , m_resultCode(result_code) {} + + ResultCode getResultCode() const { return m_resultCode; } + private: + ResultCode m_resultCode; }; - class PgConnectionError: public PgResultError, std::runtime_error { + class PgConnectionError: public PgResultError { + public: PgConnectionError(const std::string &msg, std::string result_code) : PgResultError(msg, std::move(result_code)) - , std::runtime_error(msg) {} + + private: };