Improved support from removing rows in crud tabs.
It can handle now complex selections and reports back errors encountered when removing the rows fails.
This commit is contained in:
parent
950fea873c
commit
62c6ad5bfb
10 changed files with 365 additions and 116 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef PGEXCEPTION_H
|
||||
#define PGEXCEPTION_H
|
||||
|
||||
#include "Pgsql_ErrorDetails.h"
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
|
@ -9,68 +10,39 @@ namespace Pgsql {
|
|||
|
||||
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;
|
||||
}
|
||||
explicit ResultCode(std::string result_code);
|
||||
std::string getClass() const;
|
||||
bool isClass(const std::string_view cls);
|
||||
const std::string& getSpecific() const;
|
||||
private:
|
||||
std::string m_resultCode;
|
||||
};
|
||||
|
||||
class PgException: public std::runtime_error {
|
||||
public:
|
||||
PgException(const char *msg)
|
||||
: std::runtime_error(msg)
|
||||
{}
|
||||
PgException(std::string msg)
|
||||
: std::runtime_error(msg)
|
||||
{}
|
||||
|
||||
|
||||
PgException(const char *msg);
|
||||
PgException(std::string msg);
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
class PgResultError: public PgException {
|
||||
public:
|
||||
PgResultError(std::string msg, std::string result_code)
|
||||
: PgException(std::move(msg))
|
||||
, m_resultCode(result_code)
|
||||
{}
|
||||
|
||||
ResultCode getResultCode() const { return m_resultCode; }
|
||||
PgResultError(const Pgsql::ErrorDetails &details);
|
||||
ResultCode getResultCode() const;
|
||||
const Pgsql::ErrorDetails& details() const;
|
||||
private:
|
||||
ResultCode m_resultCode;
|
||||
Pgsql::ErrorDetails m_details;
|
||||
};
|
||||
|
||||
class PgConnectionError: public PgResultError {
|
||||
public:
|
||||
PgConnectionError(const std::string &msg, std::string result_code)
|
||||
: PgResultError(msg, std::move(result_code))
|
||||
{}
|
||||
// class PgConnectionError: public PgException {
|
||||
// public:
|
||||
// PgConnectionError(const std::string &msg, std::string result_code)
|
||||
// : PgResultError(msg, std::move(result_code))
|
||||
// {}
|
||||
|
||||
private:
|
||||
// private:
|
||||
|
||||
};
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue