libpqxx
The C++ client library for PostgreSQL
except.hxx
Go to the documentation of this file.
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-2026, 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_EXCEPT_HXX
14 #define PQXX_EXCEPT_HXX
15 
16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
18 #endif
19 
20 #include <memory>
21 #include <stdexcept>
22 #include <string>
23 
24 #include "pqxx/types.hxx"
25 
26 
27 namespace pqxx
28 {
75 struct PQXX_LIBEXPORT failure : std::exception
76 {
77  failure(failure const &) = default;
78  failure(failure &&) = default;
79  explicit failure(sl loc = sl::current(), st tr = st::current()) :
80  m_block{std::make_shared<block>(loc, std::move(tr))}
81  {}
82  explicit failure(
83  std::string whatarg, sl loc = sl::current(), st tr = st::current()) :
84  m_block{
85  std::make_shared<block>(std::move(whatarg), loc, std::move(tr))}
86  {}
87 
88  ~failure() noexcept override;
89 
90  failure &operator=(failure const &) = default;
91  failure &operator=(failure &&) = default;
92 
94  [[nodiscard]] PQXX_PURE char const *what() const noexcept override
95  {
96  return m_block->message.c_str();
97  }
98 
100 
104  [[nodiscard]] PQXX_PURE sl const &location() const noexcept
105  {
106  return m_block->location;
107  }
108 
110 
123  [[nodiscard]] PQXX_PURE std::shared_ptr<st const> trace() const noexcept
124  {
125  return m_block->trace;
126  }
127 
129 
133  [[nodiscard]] PQXX_PURE std::string_view sqlstate() const noexcept
134  {
135  return m_block->sqlstate;
136  }
137 
139 
144  [[nodiscard]] PQXX_PURE std::string_view query() const noexcept
145  {
146  return m_block->statement;
147  }
148 
150 
161  [[nodiscard]] virtual bool poisons_connection() const noexcept
162  {
163  return false;
164  }
165 
167 
180  [[nodiscard]] virtual bool poisons_transaction() const noexcept
181  {
182  return false;
183  }
184 
185  // C++26: Implement using reflection.
187 
216  [[nodiscard]] virtual std::string_view name() const noexcept;
217 
218 protected:
222  std::string whatarg, std::string stat, std::string sqls,
223  sl loc = sl::current(), st tr = st::current()) :
224  m_block{std::make_shared<block>(
225  std::move(whatarg), std::move(stat), std::move(sqls), loc,
226  std::move(tr))}
227  {}
228 
229 private:
231  struct block final
232  {
233  // NOLINTBEGIN(misc-non-private-member-variables-in-classes)
234 
236  std::string message;
238  std::string statement;
240  std::string sqlstate;
242  sl location;
244  std::shared_ptr<st const> trace;
245 
246  // NOLINTEND(misc-non-private-member-variables-in-classes)
247 
248  block(sl loc, st &&tr) :
249  location{loc}, trace{make_trace_ptr(std::move(tr))}
250  {}
251 
252  block(std::string &&msg, sl loc, st &&tr) :
253  message{std::move(msg)},
254  location{loc},
255  trace{make_trace_ptr(std::move(tr))}
256  {}
257 
258  block(
259  std::string &&msg, std::string &&stat, std::string &&sqls, sl loc,
260  st &&tr) :
261  message{std::move(msg)},
262  statement{std::move(stat)},
263  sqlstate{std::move(sqls)},
264  location{loc},
265  trace{make_trace_ptr(std::move(tr))}
266  {}
267 
269 
273  [[nodiscard]] static std::shared_ptr<st const>
274  make_trace_ptr([[maybe_unused]] st &&tr)
275  {
276 #if defined(PQXX_HAVE_STACKTRACE)
277  // We have std::stacktrace support. Move tr from the stack to the heap.
278  return std::make_shared<st const>(std::move(tr));
279 #else
280  // We don't have std::stacktrace. Keep the pointer empty.
281  return {};
282 #endif
283  }
284  };
285 
287 
291  std::shared_ptr<block const> m_block;
292 };
293 
294 
296 
316 {
317  explicit broken_connection(sl loc = sl::current(), st &&tr = st::current()) :
318  failure{"Connection to database failed.", loc, std::move(tr)}
319  {}
320 
322  std::string const &whatarg, sl loc = sl::current(),
323  st &&tr = st::current()) :
324  failure{whatarg, loc, std::move(tr)}
325  {}
326 
327  [[nodiscard]] std::string_view name() const noexcept override;
328 
330  [[nodiscard]] bool poisons_connection() const noexcept override
331  {
332  return true;
333  }
334 
336  [[nodiscard]] bool poisons_transaction() const noexcept override
337  {
338  return true;
339  }
340 };
341 
342 
345 {
347  std::string const &whatarg, sl loc = sl::current(),
348  st &&tr = st::current()) :
349  broken_connection{whatarg, loc, std::move(tr)}
350  {}
351 
352  [[nodiscard]] std::string_view name() const noexcept override;
353 };
354 
355 
358 {
360  std::string const &whatarg, sl loc = sl::current(),
361  st &&tr = st::current()) :
362  failure{whatarg, loc, std::move(tr)}
363  {}
364 
365  [[nodiscard]] std::string_view name() const noexcept override;
366 };
367 
368 
370 
382 {
384  std::string const &whatarg = {}, std::string const &stmt = {},
385  std::string const &sqls = {}, sl loc = sl::current(),
386  st &&tr = st::current()) :
387  failure{whatarg, stmt, sqls, loc, std::move(tr)}
388  {}
389  sql_error(sql_error const &other) = default;
390  sql_error(sql_error &&other) = default;
391  ~sql_error() override = default;
392 
393  sql_error &operator=(sql_error const &other) = default;
394  sql_error &operator=(sql_error &&other) = default;
395 
396  [[nodiscard]] std::string_view name() const noexcept override;
397 
399  [[nodiscard]] bool poisons_transaction() const noexcept override
400  {
401  return true;
402  }
403 };
404 
405 
407 
419 {
421  std::string const &whatarg, std::string const &stmt = {},
422  std::string const &sqls = {}, sl loc = sl::current(),
423  st &&tr = st::current()) :
424  sql_error{whatarg, stmt, sqls, loc, std::move(tr)}
425  {}
426 
428  [[nodiscard]] bool poisons_connection() const noexcept override
429  {
430  return true;
431  }
432 
434  [[nodiscard]] bool poisons_transaction() const noexcept override
435  {
436  return true;
437  }
438 
439  [[nodiscard]] std::string_view name() const noexcept override;
440 };
441 
442 
444 
451 {
452  explicit in_doubt_error(
453  std::string const &whatarg, sl loc = sl::current(),
454  st &&tr = st::current()) :
455  failure{whatarg, loc, std::move(tr)}
456  {}
457 
459  [[nodiscard]] bool poisons_connection() const noexcept override
460  {
461  return true;
462  }
463 
465  [[nodiscard]] bool poisons_transaction() const noexcept override
466  {
467  return true;
468  }
469 
470  [[nodiscard]] std::string_view name() const noexcept override;
471 };
472 
473 
476 {
478  std::string const &whatarg, std::string const &q = {},
479  std::string const &sqlstate = {}, sl loc = sl::current(),
480  st &&tr = st::current()) :
481  sql_error{whatarg, q, sqlstate, loc, std::move(tr)}
482  {}
483 
485  [[nodiscard]] bool poisons_transaction() const noexcept override
486  {
487  return true;
488  }
489 
490  [[nodiscard]] std::string_view name() const noexcept override;
491 };
492 
493 
495 
504 {
506  std::string const &whatarg, std::string const &q,
507  std::string const &sqlstate = {}, sl loc = sl::current(),
508  st &&tr = st::current()) :
509  transaction_rollback{whatarg, q, sqlstate, loc, std::move(tr)}
510  {}
511 
513  [[nodiscard]] bool poisons_transaction() const noexcept override
514  {
515  return true;
516  }
517 
518  [[nodiscard]] std::string_view name() const noexcept override;
519 };
520 
521 
524 {
526  std::string const &whatarg, std::string const &q,
527  std::string const &sqlstate = {}, sl loc = sl::current(),
528  st &&tr = st::current()) :
529  transaction_rollback{whatarg, q, sqlstate, loc, std::move(tr)}
530  {}
531 
533  [[nodiscard]] bool poisons_connection() const noexcept override
534  {
535  return true;
536  }
537 
538  [[nodiscard]] std::string_view name() const noexcept override;
539 };
540 
541 
544 {
546  std::string const &whatarg, std::string const &q,
547  std::string const &sqlstate = {}, sl loc = sl::current(),
548  st &&tr = st::current()) :
549  transaction_rollback{whatarg, q, sqlstate, loc, std::move(tr)}
550  {}
551 
552  [[nodiscard]] std::string_view name() const noexcept override;
553 };
554 
555 
558 {
559  explicit internal_error(
560  std::string const &, sl = sl::current(), st &&tr = st::current());
561 
563  [[nodiscard]] bool poisons_connection() const noexcept override
564  {
565  return true;
566  }
567 
569  [[nodiscard]] bool poisons_transaction() const noexcept override
570  {
571  return true;
572  }
573 
574  [[nodiscard]] std::string_view name() const noexcept override;
575 };
576 
577 
580 {
581  explicit usage_error(
582  std::string const &whatarg, sl loc = sl::current(),
583  st &&tr = st::current()) :
584  failure{whatarg, loc, std::move(tr)}
585  {}
586 
588  [[nodiscard]] bool poisons_transaction() const noexcept override
589  {
590  return true;
591  }
592 
593  [[nodiscard]] std::string_view name() const noexcept override;
594 };
595 
596 
599 {
600  explicit argument_error(
601  std::string const &whatarg, sl loc = sl::current(),
602  st &&tr = st::current()) :
603  failure{whatarg, loc, std::move(tr)}
604  {}
605 
606  [[nodiscard]] std::string_view name() const noexcept override;
607 };
608 
609 
612 {
614  std::string const &whatarg, sl loc = sl::current(),
615  st &&tr = st::current()) :
616  failure{whatarg, loc, std::move(tr)}
617  {}
618 
619  [[nodiscard]] std::string_view name() const noexcept override;
620 };
621 
622 
625 {
626  explicit unexpected_null(
627  std::string const &whatarg, sl loc = sl::current(),
628  st &&tr = st::current()) :
629  conversion_error{whatarg, loc, std::move(tr)}
630  {}
631 
632  [[nodiscard]] std::string_view name() const noexcept override;
633 };
634 
635 
638 {
640  std::string const &whatarg, sl loc = sl::current(),
641  st &&tr = st::current()) :
642  conversion_error{whatarg, loc, std::move(tr)}
643  {}
644 
645  [[nodiscard]] std::string_view name() const noexcept override;
646 };
647 
648 
651 {
652  explicit range_error(
653  std::string const &whatarg, sl loc = sl::current(),
654  st &&tr = st::current()) :
655  failure{whatarg, loc, std::move(tr)}
656  {}
657 
658  [[nodiscard]] std::string_view name() const noexcept override;
659 };
660 
661 
664 {
665  explicit unexpected_rows(
666  std::string const &msg, sl loc = sl::current(), st &&tr = st::current()) :
667  range_error{msg, loc, std::move(tr)}
668  {}
669 
670  [[nodiscard]] std::string_view name() const noexcept override;
671 };
672 
673 
676 {
678  std::string const &err, std::string const &Q = {},
679  std::string const &sqlstate = {}, sl loc = sl::current(),
680  st &&tr = st::current()) :
681  sql_error{err, Q, sqlstate, loc, std::move(tr)}
682  {}
683 
684  [[nodiscard]] std::string_view name() const noexcept override;
685 
687  [[nodiscard]] bool poisons_connection() const noexcept override
688  {
689  return true;
690  }
691 
693  [[nodiscard]] bool poisons_transaction() const noexcept override
694  {
695  return true;
696  }
697 };
698 
699 
702 {
704  std::string const &err, std::string const &Q = {},
705  std::string const &sqlstate = {}, sl loc = sl::current(),
706  st &&tr = st::current()) :
707  sql_error{err, Q, sqlstate, loc, std::move(tr)}
708  {}
709 
710  [[nodiscard]] std::string_view name() const noexcept override;
711 };
712 
713 
715 {
717  std::string const &err, std::string const &Q = {},
718  std::string const &sqlstate = {}, sl loc = sl::current(),
719  st &&tr = st::current()) :
720  sql_error{err, Q, sqlstate, loc, std::move(tr)}
721  {}
722 
723  [[nodiscard]] std::string_view name() const noexcept override;
724 };
725 
726 
728 {
730  std::string const &err, std::string const &Q = {},
731  std::string const &sqlstate = {}, sl loc = sl::current(),
732  st &&tr = st::current()) :
733  integrity_constraint_violation{err, Q, sqlstate, loc, std::move(tr)}
734  {}
735 
736  [[nodiscard]] std::string_view name() const noexcept override;
737 };
738 
739 
741 {
743  std::string const &err, std::string const &Q = {},
744  std::string const &sqlstate = {}, sl loc = sl::current(),
745  st &&tr = st::current()) :
746  integrity_constraint_violation{err, Q, sqlstate, loc, std::move(tr)}
747  {}
748 
749  [[nodiscard]] std::string_view name() const noexcept override;
750 };
751 
752 
754 {
756  std::string const &err, std::string const &Q = {},
757  std::string const &sqlstate = {}, sl loc = sl::current(),
758  st &&tr = st::current()) :
759  integrity_constraint_violation{err, Q, sqlstate, loc, std::move(tr)}
760  {}
761 
762  [[nodiscard]] std::string_view name() const noexcept override;
763 };
764 
765 
767 {
769  std::string const &err, std::string const &Q = {},
770  std::string const &sqlstate = {}, sl loc = sl::current(),
771  st &&tr = st::current()) :
772  integrity_constraint_violation{err, Q, sqlstate, loc, std::move(tr)}
773  {}
774 
775  [[nodiscard]] std::string_view name() const noexcept override;
776 };
777 
778 
780 {
782  std::string const &err, std::string const &Q = {},
783  std::string const &sqlstate = {}, sl loc = sl::current(),
784  st &&tr = st::current()) :
785  integrity_constraint_violation{err, Q, sqlstate, loc, std::move(tr)}
786  {}
787 
788  [[nodiscard]] std::string_view name() const noexcept override;
789 };
790 
791 
793 {
795  std::string const &err, std::string const &Q = {},
796  std::string const &sqlstate = {}, sl loc = sl::current(),
797  st &&tr = st::current()) :
798  sql_error{err, Q, sqlstate, loc, std::move(tr)}
799  {}
800 
801  [[nodiscard]] std::string_view name() const noexcept override;
802 };
803 
804 
806 {
808  std::string const &err, std::string const &Q = {},
809  std::string const &sqlstate = {}, sl loc = sl::current(),
810  st &&tr = st::current()) :
811  sql_error{err, Q, sqlstate, loc, std::move(tr)}
812  {}
813 
814  [[nodiscard]] std::string_view name() const noexcept override;
815 };
816 
817 
819 {
821  std::string const &err, std::string const &Q = {},
822  std::string const &sqlstate = {}, sl loc = sl::current(),
823  st &&tr = st::current()) :
824  sql_error{err, Q, sqlstate, loc, std::move(tr)}
825  {}
826 
827  [[nodiscard]] std::string_view name() const noexcept override;
828 };
829 
830 
832 {
833  // NOLINTNEXTLINE(misc-non-private-member-variables-in-classes)
834  [[deprecated("Call error_pos() instead.")]] int error_position;
835 
837 
839  std::string const &err, std::string const &Q = {},
840  std::string const &sqlstate = {}, int pos = -1, sl loc = sl::current(),
841  st &&tr = st::current()) :
842  sql_error{err, Q, sqlstate, loc, std::move(tr)}, error_position{pos}
843  {}
844 
846 
847  [[nodiscard]] std::string_view name() const noexcept override;
848 
850 
853  [[nodiscard]] constexpr int error_pos() const noexcept
854  {
856  return error_position;
858  }
859 };
860 
861 
863 {
865  std::string const &err, std::string const &Q = {},
866  std::string const &sqlstate = {}, sl loc = sl::current(),
867  st &&tr = st::current()) :
868  // TODO: Can we get the column?
869  syntax_error{err, Q, sqlstate, -1, loc, std::move(tr)}
870  {}
871 
872  [[nodiscard]] std::string_view name() const noexcept override;
873 };
874 
875 
877 {
879  std::string const &err, std::string const &Q = {},
880  std::string const &sqlstate = {}, sl loc = sl::current(),
881  st &&tr = st::current()) :
882  // TODO: Can we get the column?
883  syntax_error{err, Q, sqlstate, -1, loc, std::move(tr)}
884  {}
885 
886  [[nodiscard]] std::string_view name() const noexcept override;
887 };
888 
889 
891 {
893  std::string const &err, std::string const &Q = {},
894  std::string const &sqlstate = {}, sl loc = sl::current(),
895  st &&tr = st::current()) :
896  // TODO: Can we get the column?
897  syntax_error{err, Q, sqlstate, -1, loc, std::move(tr)}
898  {}
899 
900  [[nodiscard]] std::string_view name() const noexcept override;
901 };
902 
903 
905 {
907  std::string const &err, std::string const &Q = {},
908  std::string const &sqlstate = {}, sl loc = sl::current(),
909  st &&tr = st::current()) :
910  sql_error{err, Q, sqlstate, loc, std::move(tr)}
911  {}
912 
913  [[nodiscard]] std::string_view name() const noexcept override;
914 };
915 
916 
919 {
921  std::string const &err, std::string const &Q = {},
922  std::string const &sqlstate = {}, sl loc = sl::current(),
923  st &&tr = st::current()) :
924  sql_error{err, Q, sqlstate, loc, std::move(tr)}
925  {}
926 
927  [[nodiscard]] std::string_view name() const noexcept override;
928 };
929 
930 
932 {
934  std::string const &err, std::string const &Q = {},
935  std::string const &sqlstate = {}, sl loc = sl::current(),
936  st &&tr = st::current()) :
937  insufficient_resources{err, Q, sqlstate, loc, std::move(tr)}
938  {}
939 
940  [[nodiscard]] std::string_view name() const noexcept override;
941 };
942 
943 
945 {
947  std::string const &err, std::string const &Q = {},
948  std::string const &sqlstate = {}, sl loc = sl::current(),
949  st &&tr = st::current()) :
950  insufficient_resources{err, Q, sqlstate, loc, std::move(tr)}
951  {}
952 
953  [[nodiscard]] std::string_view name() const noexcept override;
954 };
955 
956 
958 {
960  std::string const &err, sl loc = sl::current(), st &&tr = st::current()) :
961  broken_connection{err, loc, std::move(tr)}
962  {}
963 
964  [[nodiscard]] std::string_view name() const noexcept override;
965 };
966 
967 
969 
972 {
974  std::string const &err, std::string const &Q = {},
975  std::string const &sqlstate = {}, sl loc = sl::current(),
976  st &&tr = st::current()) :
977  sql_error{err, Q, sqlstate, loc, std::move(tr)}
978  {}
979 
980  [[nodiscard]] std::string_view name() const noexcept override;
981 };
982 
983 
986 {
988  std::string const &err, std::string const &Q = {},
989  std::string const &sqlstate = {}, sl loc = sl::current(),
990  st &&tr = st::current()) :
991  plpgsql_error{err, Q, sqlstate, loc, std::move(tr)}
992  {}
993 
994  [[nodiscard]] std::string_view name() const noexcept override;
995 };
996 
997 
999 {
1001  std::string const &err, std::string const &Q = {},
1002  std::string const &sqlstate = {}, sl loc = sl::current(),
1003  st &&tr = st::current()) :
1004  plpgsql_error{err, Q, sqlstate, loc, std::move(tr)}
1005  {}
1006 
1007  [[nodiscard]] std::string_view name() const noexcept override;
1008 };
1009 
1010 
1012 {
1014  std::string const &err, std::string const &Q = {},
1015  std::string const &sqlstate = {}, sl loc = sl::current(),
1016  st &&tr = st::current()) :
1017  plpgsql_error{err, Q, sqlstate, loc, std::move(tr)}
1018  {}
1019 
1020  [[nodiscard]] std::string_view name() const noexcept override;
1021 };
1022 
1026 } // namespace pqxx
1027 #endif
PQXX_ZARGS disk_full(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:933
bool poisons_transaction() const noexcept override
Some earlier failure broke the transaction.
Definition: except.hxx:485
in_doubt_error(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:452
PQXX_ZARGS foreign_key_violation(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:755
variable_set_to_null(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:359
virtual bool poisons_connection() const noexcept
Does this type of error make the current connection unusable?
Definition: except.hxx:161
PQXX_ZARGS data_exception(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:703
~failure() noexcept override
failure(failure const &)=default
PQXX_ZARGS integrity_constraint_violation(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:716
PQXX_ZARGS deadlock_detected(std::string const &whatarg, std::string const &q, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:545
PQXX_ZARGS plpgsql_too_many_rows(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:1013
bool poisons_connection() const noexcept override
When this happens, all bets are off. It may work, but don't risk it.
Definition: except.hxx:563
PQXX_ZARGS insufficient_resources(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:920
PQXX_PURE std::string_view sqlstate() const noexcept
SQLSTATE error code, or empty string if unavailable.
Definition: except.hxx:133
bool poisons_connection() const noexcept override
It's not advisable to continue using the connection after this.
Definition: except.hxx:533
PQXX_ZARGS transaction_rollback(std::string const &whatarg, std::string const &q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:477
PQXX_ZARGS server_out_of_memory(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:946
PQXX_PURE std::string_view query() const noexcept
SQL statement that encountered the error, if applicable; or empty string.
Definition: except.hxx:144
PQXX_ZARGS undefined_column(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:864
bool poisons_connection() const noexcept override
This kind of error can only happen when the connection breaks.
Definition: except.hxx:459
bool poisons_transaction() const noexcept override
Since the connection is broken, so is a transaction.
Definition: except.hxx:434
int error_position
Definition: except.hxx:834
PQXX_ZARGS syntax_error(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, int pos=-1, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:838
broken_connection(sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:317
PQXX_ZARGS unique_violation(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:768
PQXX_ZARGS feature_not_supported(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:677
PQXX_ZARGS not_null_violation(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:742
bool poisons_transaction() const noexcept override
When this happens, all bets are off. It may work, but don't risk it.
Definition: except.hxx:569
bool poisons_transaction() const noexcept override
To retry the transaction, you'll need to start a fresh one.
Definition: except.hxx:513
bool poisons_connection() const noexcept override
When this happens, the connection is in a confused state.
Definition: except.hxx:428
PQXX_ZARGS statement_completion_unknown(std::string const &whatarg, std::string const &q, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:525
PQXX_ZARGS check_violation(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:781
broken_connection(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:321
failure(failure &&)=default
PQXX_ZARGS invalid_cursor_name(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:820
PQXX_ZARGS invalid_cursor_state(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:794
PQXX_ZARGS plpgsql_no_data_found(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:1000
PQXX_ZARGS serialization_failure(std::string const &whatarg, std::string const &q, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:505
bool poisons_transaction() const noexcept override
Your transaction will probably still work, but something is badly wrong.
Definition: except.hxx:588
version_mismatch(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:346
usage_error(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:581
conversion_error(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:613
conversion_overrun(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:639
bool poisons_transaction() const noexcept override
When the connection breaks, so will an ongoing transaction.
Definition: except.hxx:336
range_error(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:652
sql_error & operator=(sql_error const &other)=default
bool poisons_transaction() const noexcept override
If this poisons your connection, it also poisons your transaction.
Definition: except.hxx:693
PQXX_ZARGS plpgsql_raise(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:987
PQXX_ZARGS sql_error(std::string const &whatarg={}, std::string const &stmt={}, std::string const &sqls={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:383
unexpected_null(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:626
PQXX_ZARGS plpgsql_error(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:973
sql_error & operator=(sql_error &&other)=default
virtual bool poisons_transaction() const noexcept
Does this type of error make an ongoing dbtransaction unusable?
Definition: except.hxx:180
PQXX_ZARGS insufficient_privilege(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:906
PQXX_ZARGS restrict_violation(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:729
failure(std::string whatarg, sl loc=sl::current(), st tr=st::current())
Definition: except.hxx:82
unexpected_rows(std::string const &msg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:665
sql_error(sql_error &&other)=default
too_many_connections(std::string const &err, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:959
bool poisons_transaction() const noexcept override
The transaction is already closed, and the connection is broken.
Definition: except.hxx:465
argument_error(std::string const &whatarg, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:600
PQXX_PURE std::shared_ptr< st const > trace() const noexcept
If available in this compiler, a std::stacktrace of this exception.
Definition: except.hxx:123
PQXX_ZARGS undefined_function(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:878
PQXX_ZARGS invalid_sql_statement_name(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:807
failure(sl loc=sl::current(), st tr=st::current())
Definition: except.hxx:79
protocol_violation(std::string const &whatarg, std::string const &stmt={}, std::string const &sqls={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:420
~sql_error() override=default
sql_error(sql_error const &other)=default
PQXX_PURE sl const & location() const noexcept
Best known std::source_location for where the error occurred.
Definition: except.hxx:104
PQXX_ZARGS undefined_table(std::string const &err, std::string const &Q={}, std::string const &sqlstate={}, sl loc=sl::current(), st &&tr=st::current())
Definition: except.hxx:892
Invalid argument passed to libpqxx, similar to std::invalid_argument.
Definition: except.hxx:599
Exception class for lost or failed backend connection.
Definition: except.hxx:316
Definition: except.hxx:780
Value conversion failed, e.g. when converting "Hello" to int.
Definition: except.hxx:612
Could not convert value to string: not enough buffer space.
Definition: except.hxx:638
Error in data provided to SQL statement.
Definition: except.hxx:702
The ongoing transaction has deadlocked. Retrying it may help.
Definition: except.hxx:544
Definition: except.hxx:932
Base class for all exceptions specific to libpqxx.
Definition: except.hxx:76
Database feature not supported in current setup.
Definition: except.hxx:676
Definition: except.hxx:754
"Help, I don't know whether transaction was committed successfully!"
Definition: except.hxx:451
Definition: except.hxx:905
Resource shortage on the server.
Definition: except.hxx:919
Definition: except.hxx:715
Internal error in libpqxx library.
Definition: except.hxx:558
Definition: except.hxx:819
Definition: except.hxx:793
Definition: except.hxx:806
Definition: except.hxx:741
PL/pgSQL error.
Definition: except.hxx:972
Definition: except.hxx:999
Exception raised in PL/pgSQL procedure.
Definition: except.hxx:986
Definition: except.hxx:1012
Exception class for mis-communication with the server.
Definition: except.hxx:419
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:651
Definition: except.hxx:728
Transaction failed to serialize. Please retry the whole thing.
Definition: except.hxx:504
Definition: except.hxx:945
Exception class for failed queries.
Definition: except.hxx:382
We can't tell whether our last statement succeeded.
Definition: except.hxx:524
Definition: except.hxx:832
Definition: except.hxx:958
The backend saw itself forced to roll back the ongoing transaction.
Definition: except.hxx:476
Definition: except.hxx:863
Definition: except.hxx:877
Definition: except.hxx:891
Could not convert null value: target type does not support null.
Definition: except.hxx:625
Query returned an unexpected number of rows.
Definition: except.hxx:664
Definition: except.hxx:767
Error in usage of libpqxx library, similar to std::logic_error.
Definition: except.hxx:580
The caller attempted to set a variable to null, which is not allowed.
Definition: except.hxx:358
Could not establish connection due to version mismatch.
Definition: except.hxx:345
#define PQXX_ZARGS
Definition: header-pre.hxx:136
#define PQXX_LIBEXPORT
Definition: header-pre.hxx:206
#define PQXX_PURE
Definition: header-pre.hxx:64
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38
stacktrace_placeholder st
Placeholder for future std::stacktrace.
Definition: types.hxx:68
There is no std::stacktrace on this system. Use a placeholder.
Definition: types.hxx:46
static constexpr PQXX_PURE stacktrace_placeholder current() noexcept
Placeholder for std::stacktrace::current().
Definition: types.hxx:62