libpqxx 7.7.4
except.hxx
1/* Definition of libpqxx exception classes.
2 *
3 * pqxx::sql_error, pqxx::broken_connection, pqxx::in_doubt_error, ...
4 *
5 * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/except instead.
6 *
7 * Copyright (c) 2000-2022, Jeroen T. Vermeulen.
8 *
9 * See COPYING for copyright license. If you did not receive a file called
10 * COPYING with this source code, please notify the distributor of this
11 * mistake, or contact the author.
12 */
13#ifndef PQXX_H_EXCEPT
14#define PQXX_H_EXCEPT
15
16#if !defined(PQXX_HEADER_PRE)
17# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
18#endif
19
20#include <stdexcept>
21#include <string>
22
23
24namespace pqxx
25{
43struct PQXX_LIBEXPORT failure : std::runtime_error
44{
45 explicit failure(std::string const &);
46};
47
48
50
68struct PQXX_LIBEXPORT broken_connection : failure
69{
71 explicit broken_connection(std::string const &);
72};
73
74
76struct PQXX_LIBEXPORT variable_set_to_null : failure
77{
79 explicit variable_set_to_null(std::string const &);
80};
81
82
84
87class PQXX_LIBEXPORT sql_error : public failure
88{
90 std::string const m_query;
92 std::string const m_sqlstate;
93
94public:
95 explicit sql_error(
96 std::string const &whatarg = "", std::string const &Q = "",
97 char const sqlstate[] = nullptr);
98 virtual ~sql_error() noexcept override;
99
101 [[nodiscard]] PQXX_PURE std::string const &query() const noexcept;
102
104 [[nodiscard]] PQXX_PURE std::string const &sqlstate() const noexcept;
105};
106
107
109
115struct PQXX_LIBEXPORT in_doubt_error : failure
116{
117 explicit in_doubt_error(std::string const &);
118};
119
120
122struct PQXX_LIBEXPORT transaction_rollback : sql_error
123{
124 explicit transaction_rollback(
125 std::string const &whatarg, std::string const &q = "",
126 char const sqlstate[] = nullptr);
127};
128
129
131
140{
141 explicit serialization_failure(
142 std::string const &whatarg, std::string const &q,
143 char const sqlstate[] = nullptr);
144};
145
146
149{
151 std::string const &whatarg, std::string const &q,
152 char const sqlstate[] = nullptr);
153};
154
155
158{
159 explicit deadlock_detected(
160 std::string const &whatarg, std::string const &q,
161 char const sqlstate[] = nullptr);
162};
163
164
166struct PQXX_LIBEXPORT internal_error : std::logic_error
167{
168 explicit internal_error(std::string const &);
169};
170
171
173struct PQXX_LIBEXPORT usage_error : std::logic_error
174{
175 explicit usage_error(std::string const &);
176};
177
178
180struct PQXX_LIBEXPORT argument_error : std::invalid_argument
181{
182 explicit argument_error(std::string const &);
183};
184
185
187struct PQXX_LIBEXPORT conversion_error : std::domain_error
188{
189 explicit conversion_error(std::string const &);
190};
191
192
195{
196 explicit conversion_overrun(std::string const &);
197};
198
199
201struct PQXX_LIBEXPORT range_error : std::out_of_range
202{
203 explicit range_error(std::string const &);
204};
205
206
208struct PQXX_LIBEXPORT unexpected_rows : public range_error
209{
210 explicit unexpected_rows(std::string const &msg) : range_error{msg} {}
211};
212
213
215struct PQXX_LIBEXPORT feature_not_supported : sql_error
216{
218 std::string const &err, std::string const &Q = "",
219 char const sqlstate[] = nullptr) :
220 sql_error{err, Q, sqlstate}
221 {}
222};
223
225struct PQXX_LIBEXPORT data_exception : sql_error
226{
228 std::string const &err, std::string const &Q = "",
229 char const sqlstate[] = nullptr) :
230 sql_error{err, Q, sqlstate}
231 {}
232};
233
235{
237 std::string const &err, std::string const &Q = "",
238 char const sqlstate[] = nullptr) :
239 sql_error{err, Q, sqlstate}
240 {}
241};
242
244{
246 std::string const &err, std::string const &Q = "",
247 char const sqlstate[] = nullptr) :
248 integrity_constraint_violation{err, Q, sqlstate}
249 {}
250};
251
253{
255 std::string const &err, std::string const &Q = "",
256 char const sqlstate[] = nullptr) :
257 integrity_constraint_violation{err, Q, sqlstate}
258 {}
259};
260
262{
264 std::string const &err, std::string const &Q = "",
265 char const sqlstate[] = nullptr) :
266 integrity_constraint_violation{err, Q, sqlstate}
267 {}
268};
269
271{
273 std::string const &err, std::string const &Q = "",
274 char const sqlstate[] = nullptr) :
275 integrity_constraint_violation{err, Q, sqlstate}
276 {}
277};
278
280{
282 std::string const &err, std::string const &Q = "",
283 char const sqlstate[] = nullptr) :
284 integrity_constraint_violation{err, Q, sqlstate}
285 {}
286};
287
288struct PQXX_LIBEXPORT invalid_cursor_state : sql_error
289{
291 std::string const &err, std::string const &Q = "",
292 char const sqlstate[] = nullptr) :
293 sql_error{err, Q, sqlstate}
294 {}
295};
296
298{
300 std::string const &err, std::string const &Q = "",
301 char const sqlstate[] = nullptr) :
302 sql_error{err, Q, sqlstate}
303 {}
304};
305
306struct PQXX_LIBEXPORT invalid_cursor_name : sql_error
307{
309 std::string const &err, std::string const &Q = "",
310 char const sqlstate[] = nullptr) :
311 sql_error{err, Q, sqlstate}
312 {}
313};
314
315struct PQXX_LIBEXPORT syntax_error : sql_error
316{
318 int const error_position;
319
320 explicit syntax_error(
321 std::string const &err, std::string const &Q = "",
322 char const sqlstate[] = nullptr, int pos = -1) :
323 sql_error{err, Q, sqlstate}, error_position{pos}
324 {}
325};
326
327struct PQXX_LIBEXPORT undefined_column : syntax_error
328{
330 std::string const &err, std::string const &Q = "",
331 char const sqlstate[] = nullptr) :
332 syntax_error{err, Q, sqlstate}
333 {}
334};
335
336struct PQXX_LIBEXPORT undefined_function : syntax_error
337{
339 std::string const &err, std::string const &Q = "",
340 char const sqlstate[] = nullptr) :
341 syntax_error{err, Q, sqlstate}
342 {}
343};
344
345struct PQXX_LIBEXPORT undefined_table : syntax_error
346{
348 std::string const &err, std::string const &Q = "",
349 char const sqlstate[] = nullptr) :
350 syntax_error{err, Q, sqlstate}
351 {}
352};
353
354struct PQXX_LIBEXPORT insufficient_privilege : sql_error
355{
357 std::string const &err, std::string const &Q = "",
358 char const sqlstate[] = nullptr) :
359 sql_error{err, Q, sqlstate}
360 {}
361};
362
364struct PQXX_LIBEXPORT insufficient_resources : sql_error
365{
367 std::string const &err, std::string const &Q = "",
368 char const sqlstate[] = nullptr) :
369 sql_error{err, Q, sqlstate}
370 {}
371};
372
373struct PQXX_LIBEXPORT disk_full : insufficient_resources
374{
375 explicit disk_full(
376 std::string const &err, std::string const &Q = "",
377 char const sqlstate[] = nullptr) :
378 insufficient_resources{err, Q, sqlstate}
379 {}
380};
381
383{
385 std::string const &err, std::string const &Q = "",
386 char const sqlstate[] = nullptr) :
387 insufficient_resources{err, Q, sqlstate}
388 {}
389};
390
392{
393 explicit too_many_connections(std::string const &err) :
395 {}
396};
397
399
401struct PQXX_LIBEXPORT plpgsql_error : sql_error
402{
404 std::string const &err, std::string const &Q = "",
405 char const sqlstate[] = nullptr) :
406 sql_error{err, Q, sqlstate}
407 {}
408};
409
411struct PQXX_LIBEXPORT plpgsql_raise : plpgsql_error
412{
414 std::string const &err, std::string const &Q = "",
415 char const sqlstate[] = nullptr) :
416 plpgsql_error{err, Q, sqlstate}
417 {}
418};
419
421{
423 std::string const &err, std::string const &Q = "",
424 char const sqlstate[] = nullptr) :
425 plpgsql_error{err, Q, sqlstate}
426 {}
427};
428
430{
432 std::string const &err, std::string const &Q = "",
433 char const sqlstate[] = nullptr) :
434 plpgsql_error{err, Q, sqlstate}
435 {}
436};
437
438struct PQXX_LIBEXPORT blob_already_exists : failure
439{
440 explicit blob_already_exists(std::string const &);
441};
442
446} // namespace pqxx
447#endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:27
Run-time failure encountered by libpqxx, similar to std::runtime_error.
Definition: except.hxx:44
Exception class for lost or failed backend connection.
Definition: except.hxx:69
The caller attempted to set a variable to null, which is not allowed.
Definition: except.hxx:77
Exception class for failed queries.
Definition: except.hxx:88
virtual ~sql_error() noexcept override
"Help, I don't know whether transaction was committed successfully!"
Definition: except.hxx:116
The backend saw itself forced to roll back the ongoing transaction.
Definition: except.hxx:123
Transaction failed to serialize. Please retry it.
Definition: except.hxx:140
We can't tell whether our last statement succeeded.
Definition: except.hxx:149
The ongoing transaction has deadlocked. Retrying it may help.
Definition: except.hxx:158
Internal error in libpqxx library.
Definition: except.hxx:167
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:174
Invalid argument passed to libpqxx, similar to std::invalid_argument.
Definition: except.hxx:181
Value conversion failed, e.g. when converting "Hello" to int.
Definition: except.hxx:188
Could not convert value to string: not enough buffer space.
Definition: except.hxx:195
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:202
Query returned an unexpected number of rows.
Definition: except.hxx:209
unexpected_rows(std::string const &msg)
Definition: except.hxx:210
Database feature not supported in current setup.
Definition: except.hxx:216
feature_not_supported(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:217
Error in data provided to SQL statement.
Definition: except.hxx:226
data_exception(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:227
Definition: except.hxx:235
integrity_constraint_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:236
Definition: except.hxx:244
restrict_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:245
Definition: except.hxx:253
not_null_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:254
Definition: except.hxx:262
foreign_key_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:263
Definition: except.hxx:271
unique_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:272
Definition: except.hxx:280
check_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:281
Definition: except.hxx:289
invalid_cursor_state(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:290
Definition: except.hxx:298
invalid_sql_statement_name(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:299
Definition: except.hxx:307
invalid_cursor_name(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:308
Definition: except.hxx:316
syntax_error(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr, int pos=-1)
Definition: except.hxx:320
int const error_position
Approximate position in string where error occurred, or -1 if unknown.
Definition: except.hxx:318
Definition: except.hxx:328
undefined_column(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:329
Definition: except.hxx:337
undefined_function(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:338
Definition: except.hxx:346
undefined_table(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:347
Definition: except.hxx:355
insufficient_privilege(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:356
Resource shortage on the server.
Definition: except.hxx:365
insufficient_resources(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:366
Definition: except.hxx:374
disk_full(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:375
Definition: except.hxx:383
out_of_memory(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:384
Definition: except.hxx:392
too_many_connections(std::string const &err)
Definition: except.hxx:393
PL/pgSQL error.
Definition: except.hxx:402
plpgsql_error(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:403
Exception raised in PL/pgSQL procedure.
Definition: except.hxx:412
plpgsql_raise(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:413
Definition: except.hxx:421
plpgsql_no_data_found(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:422
Definition: except.hxx:430
plpgsql_too_many_rows(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:431
Definition: except.hxx:439