libpqxx  7.7.0
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-2022, 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/types.hxx"
17 
18 
19 namespace pqxx::internal::gate
20 {
21 class errorhandler_connection;
22 }
23 
24 
25 namespace pqxx
26 {
31 
33 
49 class PQXX_LIBEXPORT errorhandler
50 {
51 public:
52  explicit errorhandler(connection &);
53  virtual ~errorhandler();
54 
57 
61  virtual bool operator()(char const msg[]) noexcept = 0;
62 
63  errorhandler() = delete;
64  errorhandler(errorhandler const &) = delete;
65  errorhandler &operator=(errorhandler const &) = delete;
66 
67 private:
68  connection *m_home;
69 
70  friend class internal::gate::errorhandler_connection;
71  void unregister() noexcept;
72 };
73 
74 
77 {
78 public:
80  quiet_errorhandler(connection &conn) : errorhandler{conn} {}
81 
83  virtual bool operator()(char const[]) noexcept override { return false; }
84 };
85 
87 } // namespace pqxx
88 #endif
Base class for error-handler callbacks.
Definition: errorhandler.hxx:49
quiet_errorhandler(connection &conn)
Suppress error notices.
Definition: errorhandler.hxx:80
virtual bool operator()(char const []) noexcept override
Revert to previous handling of error notices.
Definition: errorhandler.hxx:83
Definition: connection.hxx:94
Connection to a database.
Definition: connection.hxx:180
An error handler that suppresses any previously registered error handlers.
Definition: errorhandler.hxx:76
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:22