0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00

PostgreSQL exceptions for serialization_failure and deadlock_detected (#551)

* Add the exception sqlpp::postgresql::serialization_failure
* Add the exception sqlpp::postgresql::deadlock_detected
This commit is contained in:
MeanSquaredError 2024-01-05 10:02:32 +02:00 committed by GitHub
parent 9b49afa306
commit 0cc45bd790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -288,6 +288,28 @@ namespace sqlpp
}
};
class DLL_PUBLIC serialization_failure : public sql_error
{
public:
explicit serialization_failure(std::string err) : sql_error{std::move(err)}
{
}
serialization_failure(std::string err, std::string Q) : sql_error{std::move(err), std::move(Q)}
{
}
};
class DLL_PUBLIC deadlock_detected : public sql_error
{
public:
explicit deadlock_detected(std::string err) : sql_error{std::move(err)}
{
}
deadlock_detected(std::string err, std::string Q) : sql_error{std::move(err), std::move(Q)}
{
}
};
class DLL_PUBLIC syntax_error : public sql_error
{
public:

View File

@ -245,6 +245,11 @@ namespace sqlpp
case '4':
switch (code[1])
{
case '0':
if (strcmp(code, "40001") == 0)
throw serialization_failure{err, query};
if (strcmp(code, "40P01") == 0)
throw deadlock_detected{err, query};
case '2':
if (strcmp(code, "42501") == 0)
throw insufficient_privilege{err, query};