Some stuff I had on another machine and which might provide useful.
This commit is contained in:
parent
23e307f93a
commit
36e5526f5f
10 changed files with 325 additions and 13 deletions
1
pgsql/Pgsql_PgException.cpp
Normal file
1
pgsql/Pgsql_PgException.cpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include "Pgsql_PgException.h"
|
||||
94
pgsql/Pgsql_PgException.h
Normal file
94
pgsql/Pgsql_PgException.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#ifndef PGEXCEPTION_H
|
||||
#define PGEXCEPTION_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
namespace Pgsql {
|
||||
|
||||
class PgException {
|
||||
public:
|
||||
PgException(const char *msg)
|
||||
: message(msg)
|
||||
{}
|
||||
PgException(std::string msg)
|
||||
: message(std::move(msg))
|
||||
{}
|
||||
|
||||
|
||||
private:
|
||||
std::string message;
|
||||
|
||||
};
|
||||
|
||||
class PgResultError: public PgException {
|
||||
public:
|
||||
PgResultError(std::string msg, std::string result_code)
|
||||
: PgException(std::move(msg))
|
||||
{}
|
||||
};
|
||||
|
||||
class PgConnectionError: public PgResultError, std::runtime_error {
|
||||
PgConnectionError(const std::string &msg, std::string result_code)
|
||||
: PgResultError(msg, std::move(result_code))
|
||||
, std::runtime_error(msg)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* postgresq error classes
|
||||
*
|
||||
* success
|
||||
* warning
|
||||
* no data
|
||||
*
|
||||
* 03 sql statement not yet complete
|
||||
* 08 connection exception -> could be resolved by reconnecting / resetting connection
|
||||
* 09 triggered action exception
|
||||
* 0A feature not supported
|
||||
* 0B invalid transaction initiation
|
||||
* 0F locator exception
|
||||
* 0L invalid grantor
|
||||
* 0P invalid role
|
||||
* 0Z diagnostic exception
|
||||
* 20 case not fount
|
||||
* 21 cardinality violation
|
||||
* 22 data exception
|
||||
* 23 integrity constraint error
|
||||
* 24 invalid cursor statement
|
||||
* 25 invalid transaction state
|
||||
* 26 invalid sql statement name
|
||||
* 27 triggered data change violation
|
||||
* 28 invalid authorization specification
|
||||
* 2B Dependent Privilege Descriptors Still Exist
|
||||
* 2D Invalid Transaction Termination
|
||||
* 2F SQL Routine Exception
|
||||
* 34 Invalid Cursor Name
|
||||
* 38 External Routine Exception
|
||||
* 39 External Routine Invocation Exception
|
||||
* 3B Savepoint Exception
|
||||
* 3D Invalid Catalog Name
|
||||
* 3F Invalid Schema Name
|
||||
* 40 Transaction Rollback
|
||||
* 42 Syntax Error or Access Rule Violation
|
||||
* 44 WITH CHECK OPTION Violation
|
||||
* 53 Insufficient Resources
|
||||
* 54 Program Limit Exceeded
|
||||
* 55 Object Not In Prerequisite State
|
||||
* 57 Operator Intervention
|
||||
* 58 System Error (errors external to PostgreSQL itself)
|
||||
* 72 Snapshot Failure
|
||||
* F0 Configuration File Error
|
||||
* HV Foreign Data Wrapper Error (SQL/MED)
|
||||
* P0 PL/pgSQL Error
|
||||
* XX Internal Error
|
||||
*
|
||||
* At what levels can the communication with postgresql fail
|
||||
* - network -> reset/reconnecting
|
||||
* -
|
||||
*/
|
||||
}
|
||||
|
||||
#endif // PGEXCEPTION_H
|
||||
|
|
@ -34,6 +34,7 @@ release {
|
|||
|
||||
SOURCES += Pgsql_Connection.cpp \
|
||||
Pgsql_Params.cpp \
|
||||
Pgsql_PgException.cpp \
|
||||
Pgsql_Result.cpp \
|
||||
Pgsql_Row.cpp \
|
||||
Pgsql_Value.cpp \
|
||||
|
|
@ -43,6 +44,7 @@ SOURCES += Pgsql_Connection.cpp \
|
|||
|
||||
HEADERS += Pgsql_Connection.h \
|
||||
Pgsql_Params.h \
|
||||
Pgsql_PgException.h \
|
||||
Pgsql_Result.h \
|
||||
Pgsql_Row.h \
|
||||
Pgsql_Value.h \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue