userver: userver/formats/bson/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/bson/exception.hpp
4/// @brief BSON-specific exceptions
5
6#include <bson/bson.h>
7
8#include <userver/utils/traceful_exception.hpp>
9
10#include <string>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace formats::bson {
15
16/// Generic BSON-related exception
18public:
19 BsonException(std::string msg);
20
21 std::string_view GetMessage() const noexcept { return msg_; }
22
23private:
24 std::string msg_;
25};
26
27/// BSON parsing error
29public:
30 using BsonException::BsonException;
31};
32
34public:
35 explicit ExceptionWithPath(std::string_view msg, std::string_view path);
36
37 std::string_view GetPath() const noexcept;
38 std::string_view GetMessageWithoutPath() const noexcept;
39
40private:
41 std::size_t path_size_;
42};
43
44/// BSON types mismatch error
46public:
47 TypeMismatchException(bson_type_t actual, bson_type_t expected, std::string_view path);
48};
49
50/// BSON array indexing error
52public:
53 OutOfBoundsException(size_t index, size_t size, std::string_view path);
54};
55
56/// BSON nonexisting member access error
58public:
59 explicit MemberMissingException(std::string_view path);
60};
61
62/// Conversion error
64public:
65 ConversionException(std::string_view msg, std::string_view path);
66};
67
68} // namespace formats::bson
69
70USERVER_NAMESPACE_END