userver: userver/formats/yaml/exception.hpp Source File
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
13USERVER_NAMESPACE_BEGIN
14
15namespace formats::yaml {
16
17class Exception : public std::exception {
18 public:
19 explicit Exception(std::string msg) : msg_(std::move(msg)) {}
20
21 const char* what() const noexcept final { return msg_.c_str(); }
22
23 private:
24 std::string msg_;
25};
26
27class ParseException : public Exception {
28 public:
29 using Exception::Exception;
30};
31
33 public:
34 explicit BadStreamException(const std::istream& is);
35 explicit BadStreamException(const std::ostream& os);
36};
37
39 public:
40 TypeMismatchException(Type actual, Type expected, std::string_view path);
41 TypeMismatchException(int actual, int expected, std::string_view path);
42 TypeMismatchException(const YAML::Node& value, std::string_view expected_type,
43 std::string_view path);
44};
45
47 public:
48 OutOfBoundsException(size_t index, size_t size, std::string_view path);
49};
50
52 public:
53 explicit MemberMissingException(std::string_view path);
54};
55
57 public:
58 explicit PathPrefixException(std::string_view old_path,
59 std::string_view prefix);
60};
61
62} // namespace formats::yaml
63
64USERVER_NAMESPACE_END