libpqxx  7.7.2
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 #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 
53 class PQXX_LIBEXPORT errorhandler
54 {
55 public:
56  explicit errorhandler(connection &);
57  virtual ~errorhandler();
58 
61 
65  virtual bool operator()(char const msg[]) noexcept = 0;
66 
67  errorhandler() = delete;
68  errorhandler(errorhandler const &) = delete;
69  errorhandler &operator=(errorhandler const &) = delete;
70 
71 private:
72  connection *m_home;
73 
74  friend class internal::gate::errorhandler_connection;
75  void unregister() noexcept;
76 };
77 
78 
81 {
82 public:
84  quiet_errorhandler(connection &conn) : errorhandler{conn} {}
85 
87  virtual bool operator()(char const[]) noexcept override { return false; }
88 };
89 
91 } // namespace pqxx
92 #endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
virtual bool operator()(char const []) noexcept override
Revert to previous handling of error notices.
Definition: errorhandler.hxx:87
Connection to a database.
Definition: connection.hxx:185
quiet_errorhandler(connection &conn)
Suppress error notices.
Definition: errorhandler.hxx:84
An error handler that suppresses any previously registered error handlers.
Definition: errorhandler.hxx:80
Definition: connection.hxx:99
Base class for error-handler callbacks.
Definition: errorhandler.hxx:53