16#if !defined(PQXX_HEADER_PRE)
17# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
20#if defined(PQXX_HAVE_SOURCE_LOCATION)
21# include <source_location>
47struct PQXX_LIBEXPORT
failure : std::runtime_error
49#if defined(PQXX_HAVE_SOURCE_LOCATION)
52 std::source_location = std::source_location::current());
53 std::source_location location;
55 explicit failure(std::string
const &);
80struct PQXX_LIBEXPORT broken_connection :
failure
83 explicit broken_connection(
85#
if defined(PQXX_HAVE_SOURCE_LOCATION)
87 std::source_location = std::source_location::current()
102struct PQXX_LIBEXPORT protocol_violation : broken_connection
104 explicit protocol_violation(
106#
if defined(PQXX_HAVE_SOURCE_LOCATION)
108 std::source_location = std::source_location::current()
115struct PQXX_LIBEXPORT variable_set_to_null :
failure
117 explicit variable_set_to_null(
119#
if defined(PQXX_HAVE_SOURCE_LOCATION)
121 std::source_location = std::source_location::current()
131class PQXX_LIBEXPORT sql_error :
public failure
134 std::string
const m_query;
136 std::string
const m_sqlstate;
140 std::string
const &whatarg =
"", std::string Q =
"",
142#
if defined(PQXX_HAVE_SOURCE_LOCATION)
144 std::source_location = std::source_location::current()
147 virtual ~sql_error()
noexcept override;
150 [[nodiscard]] PQXX_PURE std::string
const &
query() const noexcept;
153 [[nodiscard]] PQXX_PURE std::
string const &
sqlstate() const noexcept;
166 explicit in_doubt_error(
168#
if defined(PQXX_HAVE_SOURCE_LOCATION)
170 std::source_location = std::source_location::current()
177struct PQXX_LIBEXPORT transaction_rollback : sql_error
179 explicit transaction_rollback(
180 std::string
const &whatarg, std::string
const &q =
"",
182#
if defined(PQXX_HAVE_SOURCE_LOCATION)
184 std::source_location = std::source_location::current()
199struct PQXX_LIBEXPORT serialization_failure : transaction_rollback
201 explicit serialization_failure(
202 std::string
const &whatarg, std::string
const &q,
204#
if defined(PQXX_HAVE_SOURCE_LOCATION)
206 std::source_location = std::source_location::current()
213struct PQXX_LIBEXPORT statement_completion_unknown : transaction_rollback
215 explicit statement_completion_unknown(
216 std::string
const &whatarg, std::string
const &q,
218#
if defined(PQXX_HAVE_SOURCE_LOCATION)
220 std::source_location = std::source_location::current()
227struct PQXX_LIBEXPORT deadlock_detected : transaction_rollback
229 explicit deadlock_detected(
230 std::string
const &whatarg, std::string
const &q,
232#
if defined(PQXX_HAVE_SOURCE_LOCATION)
234 std::source_location = std::source_location::current()
241struct PQXX_LIBEXPORT internal_error : std::logic_error
243 explicit internal_error(std::string
const &);
248struct PQXX_LIBEXPORT usage_error : std::logic_error
250 explicit usage_error(
252#
if defined(PQXX_HAVE_SOURCE_LOCATION)
254 std::source_location = std::source_location::current()
258#if defined(PQXX_HAVE_SOURCE_LOCATION)
259 std::source_location location;
265struct PQXX_LIBEXPORT argument_error : std::invalid_argument
267 explicit argument_error(
269#
if defined(PQXX_HAVE_SOURCE_LOCATION)
271 std::source_location = std::source_location::current()
275#if defined(PQXX_HAVE_SOURCE_LOCATION)
276 std::source_location location;
282struct PQXX_LIBEXPORT conversion_error : std::domain_error
284 explicit conversion_error(
286#
if defined(PQXX_HAVE_SOURCE_LOCATION)
288 std::source_location = std::source_location::current()
292#if defined(PQXX_HAVE_SOURCE_LOCATION)
293 std::source_location location;
299struct PQXX_LIBEXPORT unexpected_null : conversion_error
301 explicit unexpected_null(
303#
if defined(PQXX_HAVE_SOURCE_LOCATION)
305 std::source_location = std::source_location::current()
312struct PQXX_LIBEXPORT conversion_overrun : conversion_error
314 explicit conversion_overrun(
316#
if defined(PQXX_HAVE_SOURCE_LOCATION)
318 std::source_location = std::source_location::current()
325struct PQXX_LIBEXPORT range_error : std::out_of_range
327 explicit range_error(
329#
if defined(PQXX_HAVE_SOURCE_LOCATION)
331 std::source_location = std::source_location::current()
335#if defined(PQXX_HAVE_SOURCE_LOCATION)
336 std::source_location location;
342struct PQXX_LIBEXPORT unexpected_rows :
public range_error
344#if defined(PQXX_HAVE_SOURCE_LOCATION)
345 explicit unexpected_rows(
346 std::string
const &msg,
347 std::source_location loc = std::source_location::current()) :
348 range_error{msg, loc}
351 explicit unexpected_rows(std::string
const &msg) : range_error{msg} {}
357struct PQXX_LIBEXPORT feature_not_supported : sql_error
359#if defined(PQXX_HAVE_SOURCE_LOCATION)
360 explicit feature_not_supported(
361 std::string
const &err, std::string
const &Q =
"",
363 std::source_location loc = std::source_location::current()) :
367 explicit feature_not_supported(
368 std::string
const &err, std::string
const &Q =
"",
376struct PQXX_LIBEXPORT data_exception : sql_error
378#if defined(PQXX_HAVE_SOURCE_LOCATION)
379 explicit data_exception(
380 std::string
const &err, std::string
const &Q =
"",
382 std::source_location loc = std::source_location::current()) :
386 explicit data_exception(
387 std::string
const &err, std::string
const &Q =
"",
394struct PQXX_LIBEXPORT integrity_constraint_violation : sql_error
396#if defined(PQXX_HAVE_SOURCE_LOCATION)
397 explicit integrity_constraint_violation(
398 std::string
const &err, std::string
const &Q =
"",
400 std::source_location loc = std::source_location::current()) :
404 explicit integrity_constraint_violation(
405 std::string
const &err, std::string
const &Q =
"",
412struct PQXX_LIBEXPORT restrict_violation : integrity_constraint_violation
414#if defined(PQXX_HAVE_SOURCE_LOCATION)
415 explicit restrict_violation(
416 std::string
const &err, std::string
const &Q =
"",
418 std::source_location loc = std::source_location::current()) :
419 integrity_constraint_violation{err, Q,
sqlstate, loc}
422 explicit restrict_violation(
423 std::string
const &err, std::string
const &Q =
"",
425 integrity_constraint_violation{err, Q,
sqlstate}
430struct PQXX_LIBEXPORT not_null_violation : integrity_constraint_violation
432#if defined(PQXX_HAVE_SOURCE_LOCATION)
433 explicit not_null_violation(
434 std::string
const &err, std::string
const &Q =
"",
436 std::source_location loc = std::source_location::current()) :
437 integrity_constraint_violation{err, Q,
sqlstate, loc}
440 explicit not_null_violation(
441 std::string
const &err, std::string
const &Q =
"",
443 integrity_constraint_violation{err, Q,
sqlstate}
448struct PQXX_LIBEXPORT foreign_key_violation : integrity_constraint_violation
450#if defined(PQXX_HAVE_SOURCE_LOCATION)
451 explicit foreign_key_violation(
452 std::string
const &err, std::string
const &Q =
"",
454 std::source_location loc = std::source_location::current()) :
455 integrity_constraint_violation{err, Q,
sqlstate, loc}
458 explicit foreign_key_violation(
459 std::string
const &err, std::string
const &Q =
"",
461 integrity_constraint_violation{err, Q,
sqlstate}
466struct PQXX_LIBEXPORT unique_violation : integrity_constraint_violation
468#if defined(PQXX_HAVE_SOURCE_LOCATION)
469 explicit unique_violation(
470 std::string
const &err, std::string
const &Q =
"",
472 std::source_location loc = std::source_location::current()) :
473 integrity_constraint_violation{err, Q,
sqlstate, loc}
476 explicit unique_violation(
477 std::string
const &err, std::string
const &Q =
"",
479 integrity_constraint_violation{err, Q,
sqlstate}
484struct PQXX_LIBEXPORT check_violation : integrity_constraint_violation
486#if defined(PQXX_HAVE_SOURCE_LOCATION)
487 explicit check_violation(
488 std::string
const &err, std::string
const &Q =
"",
490 std::source_location loc = std::source_location::current()) :
491 integrity_constraint_violation{err, Q,
sqlstate, loc}
494 explicit check_violation(
495 std::string
const &err, std::string
const &Q =
"",
497 integrity_constraint_violation{err, Q,
sqlstate}
502struct PQXX_LIBEXPORT invalid_cursor_state : sql_error
504#if defined(PQXX_HAVE_SOURCE_LOCATION)
505 explicit invalid_cursor_state(
506 std::string
const &err, std::string
const &Q =
"",
508 std::source_location loc = std::source_location::current()) :
512 explicit invalid_cursor_state(
513 std::string
const &err, std::string
const &Q =
"",
520struct PQXX_LIBEXPORT invalid_sql_statement_name : sql_error
522#if defined(PQXX_HAVE_SOURCE_LOCATION)
523 explicit invalid_sql_statement_name(
524 std::string
const &err, std::string
const &Q =
"",
526 std::source_location loc = std::source_location::current()) :
530 explicit invalid_sql_statement_name(
531 std::string
const &err, std::string
const &Q =
"",
538struct PQXX_LIBEXPORT invalid_cursor_name : sql_error
540#if defined(PQXX_HAVE_SOURCE_LOCATION)
541 explicit invalid_cursor_name(
542 std::string
const &err, std::string
const &Q =
"",
544 std::source_location loc = std::source_location::current()) :
548 explicit invalid_cursor_name(
549 std::string
const &err, std::string
const &Q =
"",
556struct PQXX_LIBEXPORT syntax_error : sql_error
561#if defined(PQXX_HAVE_SOURCE_LOCATION)
562 explicit syntax_error(
563 std::string
const &err, std::string
const &Q =
"",
564 char const sqlstate[] =
nullptr,
int pos = -1,
565 std::source_location loc = std::source_location::current()) :
570 std::string
const &err, std::string
const &Q =
"",
571 char const sqlstate[] =
nullptr,
int pos = -1) :
572 sql_error{err, Q, sqlstate}, error_position{pos}
577struct PQXX_LIBEXPORT undefined_column : syntax_error
579#if defined(PQXX_HAVE_SOURCE_LOCATION)
580 explicit undefined_column(
581 std::string
const &err, std::string
const &Q =
"",
583 std::source_location loc = std::source_location::current()) :
585 syntax_error{err, Q,
sqlstate, -1, loc}
588 explicit undefined_column(
589 std::string
const &err, std::string
const &Q =
"",
596struct PQXX_LIBEXPORT undefined_function : syntax_error
598#if defined(PQXX_HAVE_SOURCE_LOCATION)
599 explicit undefined_function(
600 std::string
const &err, std::string
const &Q =
"",
602 std::source_location loc = std::source_location::current()) :
604 syntax_error{err, Q,
sqlstate, -1, loc}
607 explicit undefined_function(
608 std::string
const &err, std::string
const &Q =
"",
615struct PQXX_LIBEXPORT undefined_table : syntax_error
617#if defined(PQXX_HAVE_SOURCE_LOCATION)
618 explicit undefined_table(
619 std::string
const &err, std::string
const &Q =
"",
621 std::source_location loc = std::source_location::current()) :
623 syntax_error{err, Q,
sqlstate, -1, loc}
626 explicit undefined_table(
627 std::string
const &err, std::string
const &Q =
"",
634struct PQXX_LIBEXPORT insufficient_privilege : sql_error
636#if defined(PQXX_HAVE_SOURCE_LOCATION)
637 explicit insufficient_privilege(
638 std::string
const &err, std::string
const &Q =
"",
640 std::source_location loc = std::source_location::current()) :
644 explicit insufficient_privilege(
645 std::string
const &err, std::string
const &Q =
"",
653struct PQXX_LIBEXPORT insufficient_resources : sql_error
655#if defined(PQXX_HAVE_SOURCE_LOCATION)
656 explicit insufficient_resources(
657 std::string
const &err, std::string
const &Q =
"",
659 std::source_location loc = std::source_location::current()) :
663 explicit insufficient_resources(
664 std::string
const &err, std::string
const &Q =
"",
671struct PQXX_LIBEXPORT disk_full : insufficient_resources
673#if defined(PQXX_HAVE_SOURCE_LOCATION)
675 std::string
const &err, std::string
const &Q =
"",
677 std::source_location loc = std::source_location::current()) :
678 insufficient_resources{err, Q,
sqlstate, loc}
682 std::string
const &err, std::string
const &Q =
"",
684 insufficient_resources{err, Q,
sqlstate}
689struct PQXX_LIBEXPORT out_of_memory : insufficient_resources
691#if defined(PQXX_HAVE_SOURCE_LOCATION)
692 explicit out_of_memory(
693 std::string
const &err, std::string
const &Q =
"",
695 std::source_location loc = std::source_location::current()) :
696 insufficient_resources{err, Q,
sqlstate, loc}
699 explicit out_of_memory(
700 std::string
const &err, std::string
const &Q =
"",
702 insufficient_resources{err, Q,
sqlstate}
707struct PQXX_LIBEXPORT too_many_connections : broken_connection
709#if defined(PQXX_HAVE_SOURCE_LOCATION)
710 explicit too_many_connections(
711 std::string
const &err,
712 std::source_location loc = std::source_location::current()) :
713 broken_connection{err, loc}
716 explicit too_many_connections(std::string
const &err) :
717 broken_connection{err}
725struct PQXX_LIBEXPORT plpgsql_error : sql_error
727#if defined(PQXX_HAVE_SOURCE_LOCATION)
728 explicit plpgsql_error(
729 std::string
const &err, std::string
const &Q =
"",
731 std::source_location loc = std::source_location::current()) :
735 explicit plpgsql_error(
736 std::string
const &err, std::string
const &Q =
"",
744struct PQXX_LIBEXPORT plpgsql_raise : plpgsql_error
746#if defined(PQXX_HAVE_SOURCE_LOCATION)
747 explicit plpgsql_raise(
748 std::string
const &err, std::string
const &Q =
"",
750 std::source_location loc = std::source_location::current()) :
751 plpgsql_error{err, Q,
sqlstate, loc}
754 explicit plpgsql_raise(
755 std::string
const &err, std::string
const &Q =
"",
762struct PQXX_LIBEXPORT plpgsql_no_data_found : plpgsql_error
764#if defined(PQXX_HAVE_SOURCE_LOCATION)
765 explicit plpgsql_no_data_found(
766 std::string
const &err, std::string
const &Q =
"",
768 std::source_location loc = std::source_location::current()) :
769 plpgsql_error{err, Q,
sqlstate, loc}
772 explicit plpgsql_no_data_found(
773 std::string
const &err, std::string
const &Q =
"",
780struct PQXX_LIBEXPORT plpgsql_too_many_rows : plpgsql_error
782#if defined(PQXX_HAVE_SOURCE_LOCATION)
783 explicit plpgsql_too_many_rows(
784 std::string
const &err, std::string
const &Q =
"",
786 std::source_location loc = std::source_location::current()) :
787 plpgsql_error{err, Q,
sqlstate, loc}
790 explicit plpgsql_too_many_rows(
791 std::string
const &err, std::string
const &Q =
"",
PQXX_PURE std::string const & sqlstate() const noexcept
SQLSTATE error code if known, or empty string otherwise.
failure(std::string const &)
Definition except.cxx:23
int const error_position
Approximate position in string where error occurred, or -1 if unknown.
Definition except.hxx:559
PQXX_PURE std::string const & query() const noexcept
The query whose execution triggered the exception.
Exception class for failed queries.
Definition except.hxx:132
Definition except.hxx:557
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27