libpqxx 7.7.0
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#include <stdexcept>
17#include <string>
18
19
20namespace pqxx
21{
39struct PQXX_LIBEXPORT failure : std::runtime_error
40{
41 explicit failure(std::string const &);
42};
43
44
46
64struct PQXX_LIBEXPORT broken_connection : failure
65{
67 explicit broken_connection(std::string const &);
68};
69
70
72
75class PQXX_LIBEXPORT sql_error : public failure
76{
78 std::string const m_query;
80 std::string const m_sqlstate;
81
82public:
83 explicit sql_error(
84 std::string const &whatarg = "", std::string const &Q = "",
85 char const sqlstate[] = nullptr);
86 virtual ~sql_error() noexcept override;
87
89 [[nodiscard]] PQXX_PURE std::string const &query() const noexcept;
90
92 [[nodiscard]] PQXX_PURE std::string const &sqlstate() const noexcept;
93};
94
95
97
103struct PQXX_LIBEXPORT in_doubt_error : failure
104{
105 explicit in_doubt_error(std::string const &);
106};
107
108
110struct PQXX_LIBEXPORT transaction_rollback : sql_error
111{
112 explicit transaction_rollback(
113 std::string const &whatarg, std::string const &q = "",
114 char const sqlstate[] = nullptr);
115};
116
117
119
128{
129 explicit serialization_failure(
130 std::string const &whatarg, std::string const &q,
131 char const sqlstate[] = nullptr);
132};
133
134
137{
139 std::string const &whatarg, std::string const &q,
140 char const sqlstate[] = nullptr);
141};
142
143
146{
147 explicit deadlock_detected(
148 std::string const &whatarg, std::string const &q,
149 char const sqlstate[] = nullptr);
150};
151
152
154struct PQXX_LIBEXPORT internal_error : std::logic_error
155{
156 explicit internal_error(std::string const &);
157};
158
159
161struct PQXX_LIBEXPORT usage_error : std::logic_error
162{
163 explicit usage_error(std::string const &);
164};
165
166
168struct PQXX_LIBEXPORT argument_error : std::invalid_argument
169{
170 explicit argument_error(std::string const &);
171};
172
173
175struct PQXX_LIBEXPORT conversion_error : std::domain_error
176{
177 explicit conversion_error(std::string const &);
178};
179
180
183{
184 explicit conversion_overrun(std::string const &);
185};
186
187
189struct PQXX_LIBEXPORT range_error : std::out_of_range
190{
191 explicit range_error(std::string const &);
192};
193
194
196struct PQXX_LIBEXPORT unexpected_rows : public range_error
197{
198 explicit unexpected_rows(std::string const &msg) : range_error{msg} {}
199};
200
201
203struct PQXX_LIBEXPORT feature_not_supported : sql_error
204{
206 std::string const &err, std::string const &Q = "",
207 char const sqlstate[] = nullptr) :
208 sql_error{err, Q, sqlstate}
209 {}
210};
211
213struct PQXX_LIBEXPORT data_exception : sql_error
214{
216 std::string const &err, std::string const &Q = "",
217 char const sqlstate[] = nullptr) :
218 sql_error{err, Q, sqlstate}
219 {}
220};
221
223{
225 std::string const &err, std::string const &Q = "",
226 char const sqlstate[] = nullptr) :
227 sql_error{err, Q, sqlstate}
228 {}
229};
230
232{
234 std::string const &err, std::string const &Q = "",
235 char const sqlstate[] = nullptr) :
236 integrity_constraint_violation{err, Q, sqlstate}
237 {}
238};
239
241{
243 std::string const &err, std::string const &Q = "",
244 char const sqlstate[] = nullptr) :
245 integrity_constraint_violation{err, Q, sqlstate}
246 {}
247};
248
250{
252 std::string const &err, std::string const &Q = "",
253 char const sqlstate[] = nullptr) :
254 integrity_constraint_violation{err, Q, sqlstate}
255 {}
256};
257
259{
261 std::string const &err, std::string const &Q = "",
262 char const sqlstate[] = nullptr) :
263 integrity_constraint_violation{err, Q, sqlstate}
264 {}
265};
266
268{
270 std::string const &err, std::string const &Q = "",
271 char const sqlstate[] = nullptr) :
272 integrity_constraint_violation{err, Q, sqlstate}
273 {}
274};
275
276struct PQXX_LIBEXPORT invalid_cursor_state : sql_error
277{
279 std::string const &err, std::string const &Q = "",
280 char const sqlstate[] = nullptr) :
281 sql_error{err, Q, sqlstate}
282 {}
283};
284
286{
288 std::string const &err, std::string const &Q = "",
289 char const sqlstate[] = nullptr) :
290 sql_error{err, Q, sqlstate}
291 {}
292};
293
294struct PQXX_LIBEXPORT invalid_cursor_name : sql_error
295{
297 std::string const &err, std::string const &Q = "",
298 char const sqlstate[] = nullptr) :
299 sql_error{err, Q, sqlstate}
300 {}
301};
302
303struct PQXX_LIBEXPORT syntax_error : sql_error
304{
306 int const error_position;
307
308 explicit syntax_error(
309 std::string const &err, std::string const &Q = "",
310 char const sqlstate[] = nullptr, int pos = -1) :
311 sql_error{err, Q, sqlstate}, error_position{pos}
312 {}
313};
314
315struct PQXX_LIBEXPORT undefined_column : syntax_error
316{
318 std::string const &err, std::string const &Q = "",
319 char const sqlstate[] = nullptr) :
320 syntax_error{err, Q, sqlstate}
321 {}
322};
323
324struct PQXX_LIBEXPORT undefined_function : syntax_error
325{
327 std::string const &err, std::string const &Q = "",
328 char const sqlstate[] = nullptr) :
329 syntax_error{err, Q, sqlstate}
330 {}
331};
332
333struct PQXX_LIBEXPORT undefined_table : syntax_error
334{
336 std::string const &err, std::string const &Q = "",
337 char const sqlstate[] = nullptr) :
338 syntax_error{err, Q, sqlstate}
339 {}
340};
341
342struct PQXX_LIBEXPORT insufficient_privilege : sql_error
343{
345 std::string const &err, std::string const &Q = "",
346 char const sqlstate[] = nullptr) :
347 sql_error{err, Q, sqlstate}
348 {}
349};
350
352struct PQXX_LIBEXPORT insufficient_resources : sql_error
353{
355 std::string const &err, std::string const &Q = "",
356 char const sqlstate[] = nullptr) :
357 sql_error{err, Q, sqlstate}
358 {}
359};
360
361struct PQXX_LIBEXPORT disk_full : insufficient_resources
362{
363 explicit disk_full(
364 std::string const &err, std::string const &Q = "",
365 char const sqlstate[] = nullptr) :
366 insufficient_resources{err, Q, sqlstate}
367 {}
368};
369
371{
373 std::string const &err, std::string const &Q = "",
374 char const sqlstate[] = nullptr) :
375 insufficient_resources{err, Q, sqlstate}
376 {}
377};
378
380{
381 explicit too_many_connections(std::string const &err) :
383 {}
384};
385
387
389struct PQXX_LIBEXPORT plpgsql_error : sql_error
390{
392 std::string const &err, std::string const &Q = "",
393 char const sqlstate[] = nullptr) :
394 sql_error{err, Q, sqlstate}
395 {}
396};
397
399struct PQXX_LIBEXPORT plpgsql_raise : plpgsql_error
400{
402 std::string const &err, std::string const &Q = "",
403 char const sqlstate[] = nullptr) :
404 plpgsql_error{err, Q, sqlstate}
405 {}
406};
407
409{
411 std::string const &err, std::string const &Q = "",
412 char const sqlstate[] = nullptr) :
413 plpgsql_error{err, Q, sqlstate}
414 {}
415};
416
418{
420 std::string const &err, std::string const &Q = "",
421 char const sqlstate[] = nullptr) :
422 plpgsql_error{err, Q, sqlstate}
423 {}
424};
425
426struct PQXX_LIBEXPORT blob_already_exists : failure
427{
428 explicit blob_already_exists(std::string const &);
429};
430
434} // namespace pqxx
435#endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:23
Run-time failure encountered by libpqxx, similar to std::runtime_error.
Definition: except.hxx:40
Exception class for lost or failed backend connection.
Definition: except.hxx:65
Exception class for failed queries.
Definition: except.hxx:76
virtual ~sql_error() noexcept override
"Help, I don't know whether transaction was committed successfully!"
Definition: except.hxx:104
The backend saw itself forced to roll back the ongoing transaction.
Definition: except.hxx:111
Transaction failed to serialize. Please retry it.
Definition: except.hxx:128
We can't tell whether our last statement succeeded.
Definition: except.hxx:137
The ongoing transaction has deadlocked. Retrying it may help.
Definition: except.hxx:146
Internal error in libpqxx library.
Definition: except.hxx:155
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:162
Invalid argument passed to libpqxx, similar to std::invalid_argument.
Definition: except.hxx:169
Value conversion failed, e.g. when converting "Hello" to int.
Definition: except.hxx:176
Could not convert value to string: not enough buffer space.
Definition: except.hxx:183
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:190
Query returned an unexpected number of rows.
Definition: except.hxx:197
unexpected_rows(std::string const &msg)
Definition: except.hxx:198
Database feature not supported in current setup.
Definition: except.hxx:204
feature_not_supported(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:205
Error in data provided to SQL statement.
Definition: except.hxx:214
data_exception(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:215
Definition: except.hxx:223
integrity_constraint_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:224
Definition: except.hxx:232
restrict_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:233
Definition: except.hxx:241
not_null_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:242
Definition: except.hxx:250
foreign_key_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:251
Definition: except.hxx:259
unique_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:260
Definition: except.hxx:268
check_violation(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:269
Definition: except.hxx:277
invalid_cursor_state(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:278
Definition: except.hxx:286
invalid_sql_statement_name(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:287
Definition: except.hxx:295
invalid_cursor_name(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:296
Definition: except.hxx:304
syntax_error(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr, int pos=-1)
Definition: except.hxx:308
int const error_position
Approximate position in string where error occurred, or -1 if unknown.
Definition: except.hxx:306
Definition: except.hxx:316
undefined_column(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:317
Definition: except.hxx:325
undefined_function(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:326
Definition: except.hxx:334
undefined_table(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:335
Definition: except.hxx:343
insufficient_privilege(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:344
Resource shortage on the server.
Definition: except.hxx:353
insufficient_resources(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:354
Definition: except.hxx:362
disk_full(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:363
Definition: except.hxx:371
out_of_memory(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:372
Definition: except.hxx:380
too_many_connections(std::string const &err)
Definition: except.hxx:381
PL/pgSQL error.
Definition: except.hxx:390
plpgsql_error(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:391
Exception raised in PL/pgSQL procedure.
Definition: except.hxx:400
plpgsql_raise(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:401
Definition: except.hxx:409
plpgsql_no_data_found(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:410
Definition: except.hxx:418
plpgsql_too_many_rows(std::string const &err, std::string const &Q="", char const sqlstate[]=nullptr)
Definition: except.hxx:419
Definition: except.hxx:427