userver: userver/storages/postgres/message.hpp Source File
Loading...
Searching...
No Matches
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 {
19public:
20 enum class Severity { kLog, kDebug, kInfo, kNotice, kWarning, kError, kFatal, kPanic };
21
22 explicit Message(detail::ResultWrapperPtr);
23
24 std::string GetMessage() const;
25 std::string GetPrimary() const;
26 std::string GetDetail() const;
27 Severity GetSeverity() const;
28 std::string GetSeverityString() const;
29 SqlState GetSqlState() const;
30
31 std::string GetSchema() const;
32 std::string GetTable() const;
33 std::string GetColumn() const;
34 std::string GetDatatype() const;
35 std::string GetConstraint() const;
36
37 logging::LogExtra GetLogExtra() const;
38
39 /// @brief Throw an exception according to the SQL code
40 void ThrowException() const;
41
42 static Severity SeverityFromString(std::string_view);
43
44private:
45 detail::ResultWrapperPtr res_;
46};
47
48} // namespace storages::postgres
49
50USERVER_NAMESPACE_END