libpqxx
errorhandler.hxx
1 
13 #ifndef PQXX_H_ERRORHANDLER
14 #define PQXX_H_ERRORHANDLER
15 
16 #include "pqxx/compiler-public.hxx"
17 #include "pqxx/compiler-internal-pre.hxx"
18 
19 #include "pqxx/types.hxx"
20 
21 
22 namespace pqxx
23 {
24 namespace internal
25 {
26 namespace gate
27 {
28 class errorhandler_connection_base;
29 }
30 }
31 
37 
49 class PQXX_LIBEXPORT errorhandler
50 {
51 public:
52  explicit errorhandler(connection_base &);
53  virtual ~errorhandler();
54 
56 
60  virtual bool operator()(const char msg[]) noexcept =0;
61 
62 private:
63  connection_base *m_home;
64 
65  friend class internal::gate::errorhandler_connection_base;
66  void unregister() noexcept;
67 
68  errorhandler() =delete;
69  errorhandler(const errorhandler &) =delete;
70  errorhandler &operator=(const errorhandler &) =delete;
71 };
72 
73 
76 {
77 public:
78  quiet_errorhandler(connection_base &conn) : errorhandler(conn) {}
79 
80  virtual bool operator()(const char[]) noexcept override { return false; }
81 };
82 
87 } // namespace pqxx
88 
89 #include "pqxx/compiler-internal-post.hxx"
90 
91 #endif
quiet_errorhandler(connection_base &conn)
Definition: errorhandler.hxx:78
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:22
Base class for error-handler callbacks.
Definition: errorhandler.hxx:49
connection_base abstract base class; represents a connection to a database.
Definition: connection_base.hxx:138
virtual bool operator()(const char[]) noexcept override
Define in subclass: receive an error or warning message from the database.
Definition: errorhandler.hxx:80
An error handler that suppresses any previously registered error handlers.
Definition: errorhandler.hxx:75