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