DbError.h
1/* Copyright (C) 2026 by Marc Boris Duerner
2 SPDX-License-Identifier: LGPL-2.1-or-later WITH mif-exception
3*/
4
5#ifndef Pt_Db_DbError_h
6#define Pt_Db_DbError_h
7
8#include <Pt/Db/Api.h>
9#include <string>
10#include <stdexcept>
11
12namespace Pt {
13
14namespace Db {
15
20class PT_DB_API DbError : public std::runtime_error
21{
22 public:
25 explicit DbError(const std::string& what);
26
29 ~DbError() throw();
30};
31
32
37class PT_DB_API ConnectionError : public DbError
38{
39 public:
42 explicit ConnectionError(const std::string& what);
43
47};
48
49
54class PT_DB_API AccessDenied : public ConnectionError
55{
56 public:
59 explicit AccessDenied(const std::string& what);
60
63 ~AccessDenied() throw();
64};
65
66
71class PT_DB_API InvalidConnection : public ConnectionError
72{
73 public:
76 explicit InvalidConnection(const std::string& what);
77
81};
82
83
88class PT_DB_API QueryFailed : public DbError
89{
90 public:
93 QueryFailed(const std::string& what, const std::string& statement);
94
97 ~QueryFailed() throw();
98
101 const std::string& statement() const;
102
103 private:
104 std::string _statement;
105};
106
107
112class PT_DB_API InvalidQuery : public QueryFailed
113{
114 public:
117 InvalidQuery(const std::string& what, const std::string& statement);
118
121 ~InvalidQuery() throw();
122};
123
124
129class PT_DB_API ConstraintMismatch : public QueryFailed
130{
131 public:
134 ConstraintMismatch(const std::string& what, const std::string& statement);
135
139};
140
141
146class PT_DB_API TypeMismatch : public QueryFailed
147{
148 public:
151 TypeMismatch(const std::string& what, const std::string& statement);
152
155 ~TypeMismatch() throw();
156};
157
158} // namespace Db
159
160} // namespace Pt
161
162#endif
~AccessDenied()
Destructor.
AccessDenied(const std::string &what)
Constructs the error with message what.
~ConnectionError()
Destructor.
ConnectionError(const std::string &what)
Constructs the error with message what.
ConstraintMismatch(const std::string &what, const std::string &statement)
Constructs the error with what and the failing statement.
~ConstraintMismatch()
Destructor.
DbError(const std::string &what)
Constructs the error with message what.
~DbError()
Destructor.
~InvalidConnection()
Destructor.
InvalidConnection(const std::string &what)
Constructs the error with message what.
~InvalidQuery()
Destructor.
InvalidQuery(const std::string &what, const std::string &statement)
Constructs the error with what and the failing statement.
const std::string & statement() const
Returns the SQL statement that caused the error.
~QueryFailed()
Destructor.
QueryFailed(const std::string &what, const std::string &statement)
Constructs the error with what and the failing statement.
TypeMismatch(const std::string &what, const std::string &statement)
Constructs the error with what and the failing statement.
~TypeMismatch()
Destructor.
Portable SQL database access.
Core module.
Definition Allocator.h:33