Github   Telegram
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
6#include <iosfwd>
7#include <stdexcept>
8#include <string>
9
10#include <userver/formats/yaml/types.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace formats::yaml {
15
16class 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
26class ParseException : public Exception {
27 public:
28 using Exception::Exception;
29};
30
32 public:
33 explicit BadStreamException(const std::istream& is);
34 explicit BadStreamException(const std::ostream& os);
35};
36
38 public:
39 TypeMismatchException(Type actual, Type expected, std::string_view path);
40 TypeMismatchException(int actual, int expected, std::string_view path);
41 TypeMismatchException(const YAML::Node& value, std::string_view expected_type,
42 std::string_view path);
43};
44
46 public:
47 OutOfBoundsException(size_t index, size_t size, std::string_view path);
48};
49
51 public:
52 explicit MemberMissingException(std::string_view path);
53};
54
56 public:
57 explicit PathPrefixException(std::string_view old_path,
58 std::string_view prefix);
59};
60
61} // namespace formats::yaml
62
63USERVER_NAMESPACE_END