userver: userver/storages/postgres/message.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
message.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/storages/postgres/message.hpp
4/// @brief Database messages
5
6#include <string>
7#include <string_view>
8
9#include <userver/logging/log_extra.hpp>
10
11#include <userver/storages/postgres/postgres_fwd.hpp>
12#include <userver/storages/postgres/sql_state.hpp>
13
14USERVER_NAMESPACE_BEGIN
15
16namespace storages::postgres {
17
18class Message {
19 public:
20 enum class Severity {
21 kLog,
22 kDebug,
23 kInfo,
24 kNotice,
25 kWarning,
26 kError,
27 kFatal,
28 kPanic
29 };
30
31 explicit Message(detail::ResultWrapperPtr);
32
33 std::string GetMessage() const;
34 std::string GetPrimary() const;
35 std::string GetDetail() const;
36 Severity GetSeverity() const;
37 std::string GetSeverityString() const;
38 SqlState GetSqlState() const;
39
40 std::string GetSchema() const;
41 std::string GetTable() const;
42 std::string GetColumn() const;
43 std::string GetDatatype() const;
44 std::string GetConstraint() const;
45
46 logging::LogExtra GetLogExtra() const;
47
48 /// @brief Throw an exception according to the SQL code
49 void ThrowException() const;
50
51 static Severity SeverityFromString(std::string_view);
52
53 private:
54 detail::ResultWrapperPtr res_;
55};
56
57} // namespace storages::postgres
58
59USERVER_NAMESPACE_END