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/json/exception.hpp
4
/// @brief Exception classes for JSON module
5
/// @ingroup userver_universal
6
7
#
include
<
iosfwd
>
8
#
include
<
stdexcept
>
9
#
include
<
string
>
10
#
include
<
string_view
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
formats
::
json
{
15
16
class
Exception
:
public
std::exception {
17
public
:
18
explicit
Exception(std::string msg)
19
: msg_(std::move(msg))
20
{}
21
22
const
char
* what()
const
noexcept
final
{
return
msg_.c_str(); }
23
24
std::string_view GetMessage()
const
noexcept
{
return
msg_; }
25
26
private
:
27
std::string msg_;
28
};
29
30
class
ParseException
:
public
Exception
{
31
public
:
32
using
Exception
::Exception;
33
};
34
35
class
ExceptionWithPath
:
public
Exception
{
36
public
:
37
explicit
ExceptionWithPath(std::string_view msg, std::string_view path);
38
39
std::string_view GetPath()
const
noexcept
;
40
std::string_view GetMessageWithoutPath()
const
noexcept
;
41
42
private
:
43
std::size_t path_size_;
44
};
45
46
class
BadStreamException
:
public
Exception
{
47
public
:
48
explicit
BadStreamException(
const
std::istream& is);
49
explicit
BadStreamException(
const
std::ostream& os);
50
};
51
52
class
TypeMismatchException
:
public
ExceptionWithPath
{
53
public
:
54
TypeMismatchException(
int
actual,
int
expected, std::string_view path);
55
std::string_view GetActual()
const
;
56
std::string_view GetExpected()
const
;
57
58
private
:
59
int
actual_;
60
int
expected_;
61
};
62
63
class
OutOfBoundsException
:
public
ExceptionWithPath
{
64
public
:
65
OutOfBoundsException(size_t index, size_t size, std::string_view path);
66
};
67
68
class
MemberMissingException
:
public
ExceptionWithPath
{
69
public
:
70
explicit
MemberMissingException(std::string_view path);
71
};
72
73
/// Conversion error
74
class
ConversionException
:
public
ExceptionWithPath
{
75
public
:
76
ConversionException(std::string_view msg, std::string_view path);
77
};
78
79
class
UnknownDiscriminatorException
:
public
ExceptionWithPath
{
80
public
:
81
UnknownDiscriminatorException(std::string_view path, std::string_view discriminator_field);
82
};
83
84
}
// namespace formats::json
85
86
USERVER_NAMESPACE_END
userver
formats
json
exception.hpp
Generated on Fri Dec 5 2025 12:18:19 for userver by
Doxygen
1.13.2