10#include <fmt/format.h>
12#include <userver/storages/postgres/dsn.hpp>
13#include <userver/storages/postgres/io/traits.hpp>
14#include <userver/storages/postgres/message.hpp>
16#include <userver/compiler/demangle.hpp>
17#include <userver/utils/underlying_value.hpp>
19USERVER_NAMESPACE_BEGIN
27std::string OidPrettyPrint(Oid oid);
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
177class Error :
public std::runtime_error {
178 using runtime_error::runtime_error;
200template <
typename Base>
203 explicit ServerError(
const Message& msg) : Base(msg.GetMessage()), msg_{msg} {}
205 const Message& GetServerMessage()
const {
return msg_; }
207 Message::Severity GetSeverity()
const {
return msg_.GetSeverity(); }
208 SqlState GetSqlState()
const {
return msg_.GetSqlState(); }
227 explicit ConnectionFailed(
const Dsn& dsn);
228 ConnectionFailed(
const Dsn& dsn, std::string_view message);
241 PoolError(std::string_view msg, std::string_view db_name);
242 PoolError(std::string_view msg);
283 using ServerLogicError::ServerLogicError;
290 using ServerRuntimeError::ServerRuntimeError;
297 using ServerLogicError::ServerLogicError;
304 using ServerRuntimeError::ServerRuntimeError;
311 using ServerRuntimeError::ServerRuntimeError;
318 using ServerLogicError::ServerLogicError;
325 using ServerRuntimeError::ServerRuntimeError;
332 using ServerLogicError::ServerLogicError;
341 using ServerRuntimeError::ServerRuntimeError;
352 using ServerRuntimeError::ServerRuntimeError;
354 std::string GetSchema()
const;
355 std::string GetTable()
const;
356 std::string GetConstraint()
const;
397 using ServerRuntimeError::ServerRuntimeError;
404 using ServerRuntimeError::ServerRuntimeError;
412 using ServerRuntimeError::ServerRuntimeError;
425 using ServerLogicError::ServerLogicError;
432 using ServerLogicError::ServerLogicError;
439 using ServerRuntimeError::ServerRuntimeError;
446 using ServerRuntimeError::ServerRuntimeError;
453 using ServerRuntimeError::ServerRuntimeError;
460 using ServerRuntimeError::ServerRuntimeError;
467 using ServerRuntimeError::ServerRuntimeError;
474 using ServerRuntimeError::ServerRuntimeError;
481 using ServerRuntimeError::ServerRuntimeError;
488 using ServerLogicError::ServerLogicError;
492 using ServerLogicError::ServerLogicError;
496 using ServerLogicError::ServerLogicError;
504 using ServerRuntimeError::ServerRuntimeError;
511 using ServerRuntimeError::ServerRuntimeError;
518 using ServerRuntimeError::ServerRuntimeError;
525 using ServerRuntimeError::ServerRuntimeError;
552 using ServerRuntimeError::ServerRuntimeError;
559 using ServerRuntimeError::ServerRuntimeError;
566 using ServerRuntimeError::ServerRuntimeError;
573 using ServerRuntimeError::ServerRuntimeError;
580 using ServerRuntimeError::ServerRuntimeError;
587 using ServerRuntimeError::ServerRuntimeError;
600 AlreadyInTransaction();
606 NotInTransaction(
const std::string& msg);
611 TransactionForceRollback();
612 TransactionForceRollback(
const std::string& msg);
622 ResultSetError(std::string msg);
624 void AddMsgSuffix(std::string_view str);
625 void AddMsgPrefix(std::string_view str);
627 const char* what()
const noexcept override;
636 RowIndexOutOfBounds(std::size_t index);
642 FieldIndexOutOfBounds(std::size_t index);
648 FieldNameDoesntExist(std::string_view name);
655 template <
typename T>
656 FieldValueIsNull(std::size_t field_index, std::string_view field_name,
const T&)
658 "Field #{} name `{}` C++ type `{}` value is null, forgot `std::optional`?",
670 TypeCannotBeNull(std::string_view type);
686 UnknownBufferCategory(std::string_view context, Oid type_oid);
687 UnknownBufferCategory(Oid type_oid, std::string_view cpp_field_type, std::string_view cpp_composite_type);
707 InvalidBinaryBuffer(
const std::string& message);
714 InvalidTupleSizeRequested(std::size_t field_count, std::size_t tuple_size);
721 NonSingleColumnResultSet(std::size_t actual_size, std::string_view type_name, std::string_view func);
727 explicit NonSingleRowResultSet(std::size_t actual_size);
734 FieldTupleMismatch(std::size_t field_count, std::size_t tuple_size);
749 CompositeSizeMismatch(std::size_t pg_size, std::size_t cpp_size, std::string_view cpp_type);
756 CompositeMemberTypeMismatch(
757 std::string_view pg_type_schema,
758 std::string_view pg_type_name,
759 std::string_view field_name,
783 InvalidDimensions(std::size_t expected, std::size_t actual);
827 InvalidEnumerationLiteral(std::string_view type_name, std::string_view literal);
832 template <
typename Enum>
833 explicit InvalidEnumerationValue(Enum val)
835 "Invalid enumeration value '{}' for enum type '{}'",
836 USERVER_NAMESPACE::
utils::UnderlyingValue(val),
846 UnsupportedInterval();
852 BoundedRangeError(std::string_view message);
867 BitStringOverflow(std::size_t actual, std::size_t expected);
873 InvalidBitStringRepresentation();
881 InvalidDSN(std::string_view dsn, std::string_view err);
903 explicit IpAddressInvalidFormat(std::string_view str);