userver
C++ Async Framework
Loading...
Searching...
No Matches
exception.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/formats/yaml/exception.hpp
4
/// @brief Exception classes for YAML module
5
/// @ingroup userver_universal
6
7
#
include
<
iosfwd
>
8
#
include
<
stdexcept
>
9
#
include
<
string
>
10
11
#
include
<
userver
/
formats
/
yaml
/
types
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
/// @brief YAML document model (`formats::yaml::Value`) and helpers.
16
namespace
formats::
yaml
{
17
18
class
Exception
:
public
std::exception {
19
public
:
20
explicit
Exception(std::string msg)
21
: msg_(std::move(msg))
22
{}
23
24
const
char
* what()
const
noexcept
final
;
25
26
std::string_view GetMessage()
const
noexcept
{
return
msg_; }
27
28
private
:
29
std::string msg_;
30
};
31
32
class
ParseException
:
public
Exception
{
33
public
:
34
using
Exception
::Exception;
35
36
ParseException(
const
ParseException
&) =
default
;
37
ParseException(
ParseException
&&) =
default
;
38
ParseException
& operator=(
const
ParseException
&) =
default
;
39
ParseException
& operator=(
ParseException
&&) =
default
;
40
41
~ParseException()
override
;
42
};
43
44
class
ExceptionWithPath
:
public
Exception
{
45
public
:
46
explicit
ExceptionWithPath(std::string_view msg, std::string_view path);
47
48
std::string_view GetPath()
const
noexcept
;
49
std::string_view GetMessageWithoutPath()
const
noexcept
;
50
51
private
:
52
std::size_t path_size_;
53
};
54
55
class
BadStreamException
:
public
Exception
{
56
public
:
57
explicit
BadStreamException(
const
std::istream& is);
58
explicit
BadStreamException(
const
std::ostream& os);
59
};
60
61
class
TypeMismatchException
:
public
ExceptionWithPath
{
62
public
:
63
TypeMismatchException(
Type
actual,
Type
expected, std::string_view path);
64
TypeMismatchException(
int
actual,
int
expected, std::string_view path);
65
TypeMismatchException(
const
YAML::Node& value, std::string_view expected_type, std::string_view path);
66
};
67
68
class
OutOfBoundsException
:
public
ExceptionWithPath
{
69
public
:
70
OutOfBoundsException(size_t index, size_t size, std::string_view path);
71
};
72
73
class
MemberMissingException
:
public
ExceptionWithPath
{
74
public
:
75
explicit
MemberMissingException(std::string_view path);
76
};
77
78
class
PathPrefixException
:
public
Exception
{
79
public
:
80
explicit
PathPrefixException(std::string_view old_path, std::string_view prefix);
81
};
82
83
}
// namespace formats::yaml
84
85
USERVER_NAMESPACE_END
userver
formats
yaml
exception.hpp
Generated on Thu May 21 2026 16:16:03 for userver by
Doxygen
1.13.2