libpqxx  7.3.1
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-2021, 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 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/internal/compiler-internal-pre.hxx"
18 
19 #include "pqxx/types.hxx"
20 
21 
22 namespace pqxx::internal::gate
23 {
24 class errorhandler_connection;
25 }
26 
27 
28 namespace pqxx
29 {
34 
36 
52 class PQXX_LIBEXPORT errorhandler
53 {
54 public:
55  explicit errorhandler(connection &);
56  virtual ~errorhandler();
57 
60 
64  virtual bool operator()(char const msg[]) noexcept = 0;
65 
66  errorhandler() = delete;
67  errorhandler(errorhandler const &) = delete;
68  errorhandler &operator=(errorhandler const &) = delete;
69 
70 private:
71  connection *m_home;
72 
73  friend class internal::gate::errorhandler_connection;
74  void unregister() noexcept;
75 };
76 
77 
80 {
81 public:
83  quiet_errorhandler(connection &conn) : errorhandler{conn} {}
84 
86  virtual bool operator()(char const[]) noexcept override { return false; }
87 };
88 
90 } // namespace pqxx
91 
92 #include "pqxx/internal/compiler-internal-post.hxx"
93 #endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
An error handler that suppresses any previously registered error handlers.
Definition: errorhandler.hxx:79
quiet_errorhandler(connection &conn)
Suppress error notices.
Definition: errorhandler.hxx:83
Base class for error-handler callbacks.
Definition: errorhandler.hxx:52
virtual bool operator()(char const []) noexcept override
Revert to previous handling of error notices.
Definition: errorhandler.hxx:86
Definition: connection.hxx:94
Connection to a database.
Definition: connection.hxx:169