userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
exception.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/odbc/exception.hpp
4
/// @brief ODBC storage exception hierarchy
5
6
#
include
<
cstddef
>
7
#
include
<
stdexcept
>
8
#
include
<
string
>
9
#
include
<
string_view
>
10
#
include
<
vector
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
storages::
odbc
{
15
16
/// A single diagnostic record reported by the ODBC driver manager or driver.
17
struct
DiagnosticRecord
final
{
18
std::string sql_state;
19
int
native_error{0};
20
std::string message;
21
};
22
23
class
Error
:
public
std::runtime_error {
24
using
std::runtime_error::runtime_error;
25
};
26
27
class
LogicError
:
public
Error
{
28
using
Error
::Error;
29
};
30
31
class
RuntimeError
:
public
Error
{
32
public
:
33
using
Error
::Error;
34
35
RuntimeError(std::string message, std::vector<DiagnosticRecord> diagnostics,
bool
invalid_handle =
false
);
36
37
/// Structured driver diagnostics, in the order returned by ODBC.
38
const
std::vector<DiagnosticRecord>&
GetDiagnostics
()
const
noexcept
;
39
40
/// Whether any diagnostic has the specified two-character SQLSTATE class.
41
bool
HasSqlStateClass
(std::string_view sql_state_class)
const
noexcept
;
42
43
/// Whether the failed ODBC call returned SQL_INVALID_HANDLE.
44
bool
IsInvalidHandle
()
const
noexcept
;
45
46
private
:
47
std::vector<DiagnosticRecord> diagnostics_;
48
bool
invalid_handle_{
false
};
49
};
50
51
class
ConnectionError
:
public
RuntimeError
{
52
using
RuntimeError
::RuntimeError;
53
};
54
55
class
StatementError
:
public
RuntimeError
{
56
using
RuntimeError
::RuntimeError;
57
};
58
59
/// Thrown when an ODBC pool cannot provide a connection for a non-timeout reason.
60
class
PoolError
:
public
RuntimeError
{
61
using
RuntimeError
::RuntimeError;
62
};
63
64
/// Thrown when the operation is aborted because an @ref engine::Deadline has expired
65
/// (including task-inherited request deadlines).
66
class
OperationInterrupted
:
public
RuntimeError
{
67
using
RuntimeError
::RuntimeError;
68
};
69
70
class
TransactionException
:
public
LogicError
{
71
using
LogicError
::LogicError;
72
};
73
74
class
ResultSetError
:
public
RuntimeError
{
75
using
RuntimeError
::RuntimeError;
76
};
77
78
class
RowIndexOutOfBounds
:
public
ResultSetError
{
79
public
:
80
explicit
RowIndexOutOfBounds(std::size_t index);
81
};
82
83
class
FieldIndexOutOfBounds
:
public
ResultSetError
{
84
public
:
85
explicit
FieldIndexOutOfBounds(std::size_t index);
86
};
87
88
}
// namespace storages::odbc
89
90
USERVER_NAMESPACE_END
odbc
include
userver
storages
odbc
exception.hpp
Generated on
for userver by
Doxygen
1.17.0