libpqxx
The C++ client library for PostgreSQL
errorhandler.hxx
1 /* Definition of the pqxx::errorhandler class.
2  *
3  * pqxx::errorhandler handlers errors and warnings in a database session.
4  *
5  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/errorhandler instead.
6  *
7  * Copyright (c) 2000-2025, 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_ERRORHANDLER
14 #define PQXX_H_ERRORHANDLER
15 
16 #if !defined(PQXX_HEADER_PRE)
17 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
18 #endif
19 
20 #include "pqxx/types.hxx"
21 
22 
23 namespace pqxx::internal::gate
24 {
25 class errorhandler_connection;
26 }
27 
28 
29 namespace pqxx
30 {
35 
37 
45 class PQXX_LIBEXPORT errorhandler
46 {
47 public:
48  [[deprecated("Use a notice handler instead.")]]
49  explicit errorhandler(connection &);
50  virtual ~errorhandler();
51 
54 
58  virtual bool operator()(char const msg[]) noexcept = 0;
59 
60  errorhandler() = delete;
61  errorhandler(errorhandler const &) = delete;
62  errorhandler &operator=(errorhandler const &) = delete;
63 
64 private:
65  connection *m_home;
66 
68  void unregister() noexcept;
69 };
70 
71 
74 {
75 public:
76 #include "pqxx/internal/ignore-deprecated-pre.hxx"
78  [[deprecated("Use notice handlers instead.")]]
80  errorhandler{cx}
81  {}
82 #include "pqxx/internal/ignore-deprecated-post.hxx"
83 
85  virtual bool operator()(char const[]) noexcept override { return false; }
86 };
87 
89 } // namespace pqxx
90 #endif
Definition: errorhandler-connection.hxx:5
quiet_errorhandler(connection &cx)
Suppress error notices.
Definition: errorhandler.hxx:79
Definition: connection.hxx:106
Definition: errorhandler.hxx:45
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
Connection to a database.
Definition: connection.hxx:278
Definition: errorhandler.hxx:73
virtual bool operator()(char const []) noexcept override
End a code block started by "ignore-deprecated-pre.hxx".
Definition: errorhandler.hxx:85