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
5
6#include <bson/bson.h>
7
9
10#include <string>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace formats::bson {
15
17class BsonException : public utils::TracefulException {
18public:
19 BsonException(std::string msg);
20
21 std::string_view GetMessage() const noexcept { return msg_; }
22
23private:
24 std::string msg_;
25};
26
28class ParseException : public BsonException {
29public:
30 using BsonException::BsonException;
31};
32
33class ExceptionWithPath : public BsonException {
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
45class TypeMismatchException : public ExceptionWithPath {
46public:
47 TypeMismatchException(bson_type_t actual, bson_type_t expected, std::string_view path);
48};
49
51class OutOfBoundsException : public ExceptionWithPath {
52public:
53 OutOfBoundsException(size_t index, size_t size, std::string_view path);
54};
55
57class MemberMissingException : public ExceptionWithPath {
58public:
59 explicit MemberMissingException(std::string_view path);
60};
61
63class ConversionException : public ExceptionWithPath {
64public:
65 ConversionException(std::string_view msg, std::string_view path);
66};
67
68} // namespace formats::bson
69
70USERVER_NAMESPACE_END