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) : msg_(std::move(msg)) {}
19
20
const
char
* what()
const
noexcept
final
{
return
msg_.c_str(); }
21
22
private
:
23
std::string msg_;
24
};
25
26
class
ParseException
:
public
Exception
{
27
public
:
28
using
Exception
::Exception;
29
};
30
31
class
BadStreamException
:
public
Exception
{
32
public
:
33
explicit
BadStreamException(
const
std::istream& is);
34
explicit
BadStreamException(
const
std::ostream& os);
35
};
36
37
class
TypeMismatchException
:
public
Exception
{
38
public
:
39
TypeMismatchException(
int
actual,
int
expected,
const
std::string& path);
40
std::string_view GetActual()
const
;
41
std::string_view GetExpected()
const
;
42
const
std::string& GetPath()
const
noexcept
;
43
44
private
:
45
int
actual_;
46
int
expected_;
47
std::string path_;
48
};
49
50
class
OutOfBoundsException
:
public
Exception
{
51
public
:
52
OutOfBoundsException(size_t index, size_t size,
const
std::string& path);
53
const
std::string& GetPath()
const
noexcept
;
54
55
private
:
56
std::string path_;
57
};
58
59
class
MemberMissingException
:
public
Exception
{
60
public
:
61
explicit
MemberMissingException(
const
std::string& path);
62
};
63
64
/// Conversion error
65
class
ConversionException
:
public
Exception
{
66
public
:
67
using
Exception
::Exception;
68
};
69
70
}
// namespace formats::json
71
72
USERVER_NAMESPACE_END
userver
formats
json
exception.hpp
Generated on Wed Oct 4 2023 12:19:42 for userver by
Doxygen
1.9.8