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
namespace
formats
::
yaml
{
16
17
class
Exception
:
public
std::exception {
18
public
:
19
explicit
Exception(std::string msg)
20
: msg_(std::move(msg))
21
{}
22
23
const
char
* what()
const
noexcept
final
{
return
msg_.c_str(); }
24
25
std::string_view GetMessage()
const
noexcept
{
return
msg_; }
26
27
private
:
28
std::string msg_;
29
};
30
31
class
ParseException
:
public
Exception
{
32
public
:
33
using
Exception
::Exception;
34
};
35
36
class
ExceptionWithPath
:
public
Exception
{
37
public
:
38
explicit
ExceptionWithPath(std::string_view msg, std::string_view path);
39
40
std::string_view GetPath()
const
noexcept
;
41
std::string_view GetMessageWithoutPath()
const
noexcept
;
42
43
private
:
44
std::size_t path_size_;
45
};
46
47
class
BadStreamException
:
public
Exception
{
48
public
:
49
explicit
BadStreamException(
const
std::istream& is);
50
explicit
BadStreamException(
const
std::ostream& os);
51
};
52
53
class
TypeMismatchException
:
public
ExceptionWithPath
{
54
public
:
55
TypeMismatchException(
Type
actual,
Type
expected, std::string_view path);
56
TypeMismatchException(
int
actual,
int
expected, std::string_view path);
57
TypeMismatchException(
const
YAML::Node& value, std::string_view expected_type, std::string_view path);
58
};
59
60
class
OutOfBoundsException
:
public
ExceptionWithPath
{
61
public
:
62
OutOfBoundsException(size_t index, size_t size, std::string_view path);
63
};
64
65
class
MemberMissingException
:
public
ExceptionWithPath
{
66
public
:
67
explicit
MemberMissingException(std::string_view path);
68
};
69
70
class
PathPrefixException
:
public
Exception
{
71
public
:
72
explicit
PathPrefixException(std::string_view old_path, std::string_view prefix);
73
};
74
75
}
// namespace formats::yaml
76
77
USERVER_NAMESPACE_END
userver
formats
yaml
exception.hpp
Generated on Fri Dec 5 2025 12:18:19 for userver by
Doxygen
1.13.2