relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
Loading...
Searching...
No Matches
relx::connection::PostgreSQLError Struct Reference

Specialized ConnectionError for PostgreSQL with detailed error information. More...

#include <relx/connection/postgresql_errors.hpp>

Public Member Functions

std::string formatted_message () const
 Get a user-friendly error message.
 
bool is_duplicate_key_error () const
 Check if this is a duplicate key error.
 
bool is_foreign_key_violation () const
 Check if this is a foreign key violation.
 
bool is_check_constraint_violation () const
 Check if this is a check constraint violation.
 
bool is_not_null_violation () const
 Check if this is a not-null violation.
 

Static Public Member Functions

static PostgreSQLError from_libpq (int pg_error_code, std::string_view error_msg)
 Create an error from a libpq error code and message.
 
static PostgreSQLError from_sql_state (std::string_view sql_state, std::string_view error_msg)
 Create an error from a SQLSTATE code.
 

Public Attributes

std::string message
 
PostgreSQLErrorCode error_code = PostgreSQLErrorCode::Unknown
 
std::string sql_state
 
std::string constraint_name
 
std::string table_name
 
std::string column_name
 
std::string detail
 
std::string hint
 

Detailed Description

Specialized ConnectionError for PostgreSQL with detailed error information.

Definition at line 36 of file postgresql_errors.hpp.

Member Function Documentation

◆ formatted_message()

std::string relx::connection::PostgreSQLError::formatted_message ( ) const

Get a user-friendly error message.

Returns
A formatted error message with details

◆ from_libpq()

static PostgreSQLError relx::connection::PostgreSQLError::from_libpq ( int  pg_error_code,
std::string_view  error_msg 
)
static

Create an error from a libpq error code and message.

Parameters
pg_error_codeThe PostgreSQL error code
error_msgThe error message

◆ from_sql_state()

static PostgreSQLError relx::connection::PostgreSQLError::from_sql_state ( std::string_view  sql_state,
std::string_view  error_msg 
)
static

Create an error from a SQLSTATE code.

Parameters
sql_stateThe SQLSTATE code
error_msgThe error message

◆ is_check_constraint_violation()

bool relx::connection::PostgreSQLError::is_check_constraint_violation ( ) const
inline

Check if this is a check constraint violation.

Returns
True if this is a check constraint violation

Definition at line 72 of file postgresql_errors.hpp.

◆ is_duplicate_key_error()

bool relx::connection::PostgreSQLError::is_duplicate_key_error ( ) const
inline

Check if this is a duplicate key error.

Returns
True if this is a duplicate key error

Definition at line 62 of file postgresql_errors.hpp.

◆ is_foreign_key_violation()

bool relx::connection::PostgreSQLError::is_foreign_key_violation ( ) const
inline

Check if this is a foreign key violation.

Returns
True if this is a foreign key violation

Definition at line 66 of file postgresql_errors.hpp.

◆ is_not_null_violation()

bool relx::connection::PostgreSQLError::is_not_null_violation ( ) const
inline

Check if this is a not-null violation.

Returns
True if this is a not-null violation

Definition at line 78 of file postgresql_errors.hpp.

Member Data Documentation

◆ column_name

std::string relx::connection::PostgreSQLError::column_name

Definition at line 42 of file postgresql_errors.hpp.

◆ constraint_name

std::string relx::connection::PostgreSQLError::constraint_name

Definition at line 40 of file postgresql_errors.hpp.

◆ detail

std::string relx::connection::PostgreSQLError::detail

Definition at line 43 of file postgresql_errors.hpp.

◆ error_code

PostgreSQLErrorCode relx::connection::PostgreSQLError::error_code = PostgreSQLErrorCode::Unknown

Definition at line 38 of file postgresql_errors.hpp.

◆ hint

std::string relx::connection::PostgreSQLError::hint

Definition at line 44 of file postgresql_errors.hpp.

◆ message

std::string relx::connection::PostgreSQLError::message

Definition at line 37 of file postgresql_errors.hpp.

◆ sql_state

std::string relx::connection::PostgreSQLError::sql_state

Definition at line 39 of file postgresql_errors.hpp.

◆ table_name

std::string relx::connection::PostgreSQLError::table_name

Definition at line 41 of file postgresql_errors.hpp.


The documentation for this struct was generated from the following file: