pgLab/pgsql/Pgsql_PgException.h

95 lines
2.3 KiB
C
Raw Normal View History

#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