userver: userver/formats/json/parser/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/json/parser/exception.hpp
4/// @brief Exception types for JSON streaming parsers.
5/// @ingroup userver_universal
6
7#include <stdexcept>
8
9#include <fmt/format.h>
10
11#include <userver/formats/json/exception.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace formats::json::parser {
16
17class BaseError : public formats::json::Exception {
18public:
19 using Exception::Exception;
20
21 BaseError(const BaseError&) = default;
22 BaseError(BaseError&&) = default;
23 BaseError& operator=(const BaseError&) = default;
24 BaseError& operator=(BaseError&&) = default;
25
26 ~BaseError() override;
27};
28
29class ParseError : public BaseError {
30public:
31 ParseError(size_t pos, std::string_view path, std::string what)
32 : BaseError(fmt::format("Parse error at pos {}, path '{}': {}", pos, path, what))
33 {}
34
35 ParseError(const ParseError&) = default;
36 ParseError(ParseError&&) = default;
37 ParseError& operator=(const ParseError&) = default;
38 ParseError& operator=(ParseError&&) = default;
39
40 ~ParseError() override;
41};
42
44public:
45 using BaseError::BaseError;
46
47 InternalParseError(const InternalParseError&) = default;
48 InternalParseError(InternalParseError&&) = default;
49 InternalParseError& operator=(const InternalParseError&) = default;
50 InternalParseError& operator=(InternalParseError&&) = default;
51
52 ~InternalParseError() override;
53};
54
55} // namespace formats::json::parser
56
57USERVER_NAMESPACE_END