AnCH Framework
0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
mappingError.hpp
1
/*
2
ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3
Copyright (C) 2020 Vincent Lachenal
4
5
This file is part of ANCH Framework.
6
7
ANCH Framework is free software: you can redistribute it and/or modify
8
it under the terms of the GNU Lesser General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
ANCH Framework is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU Lesser General Public License for more details.
16
17
You should have received a copy of the GNU Lesser General Public License
18
along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19
*/
20
#pragma once
21
22
#include "anch-json-export.hpp"
23
24
#include <istream>
25
#include <exception>
26
#include <optional>
27
#include <string>
28
#include <string_view>
29
#include <cstddef>
30
31
#include "json/readerContext.hpp"
32
33
34
namespace
anch::json
{
35
43
enum class
ErrorCode
{
45
INVALID_FORMAT = 0,
46
48
UNEXPECTED_FIELD
,
49
51
POTENTIAL_OVERFLOW
,
52
57
MISSING_FIELD
,
58
63
CONSTRAINT_VIOLATION,
64
69
PAYLOAD_TOO_LARGE
,
70
72
UNKNOWN
= 9999
73
};
74
84
class
ANCH_JSON_EXPORT
MappingError
:
public
std::exception {
85
86
// Attributes +
87
private
:
89
ErrorCode
_code;
90
92
std::string _msg;
93
95
std::string _detail;
96
98
std::string _path;
99
// Attributes -
100
101
// Constructors +
102
public
:
109
MappingError
(
ErrorCode
code,
const
anch::json::ReaderContext
& context);
110
119
MappingError
(
ErrorCode
code,
const
anch::json::ReaderContext
& context, std::string_view message);
120
129
MappingError
(
ErrorCode
code, std::string_view message);
130
// Constructors -
131
132
// Destructor +
133
public
:
137
virtual
~MappingError
();
138
// Destructor -
139
140
// Methods +
141
public
:
147
virtual
const
char
*
what
() const noexcept override;
148
157
void
prependField
(std::string_view field);
158
167
void
prependIndex
(std::
size_t
index);
168
169
private:
173
void
computeMessage();
174
// Methods -
175
176
// Accessors +
177
public:
183
anch
::
json
::
ErrorCode
getErrorCode
() const;
184
196
const std::
string
&
getPath
() const;
197
// Accessors -
198
199
};
200
201
}
// anch::json
202
203
#include "json/impl/mappingError.hpp"
anch::json::MappingError::MappingError
MappingError(ErrorCode code, const anch::json::ReaderContext &context, std::string_view message)
anch::json::MappingError::what
virtual const char * what() const noexcept override
anch::json::MappingError::getPath
const std::string & getPath() const
anch::json::MappingError::~MappingError
virtual ~MappingError()
anch::json::MappingError::getErrorCode
anch::json::ErrorCode getErrorCode() const
anch::json::MappingError::prependIndex
void prependIndex(std::size_t index)
anch::json::MappingError::MappingError
MappingError(ErrorCode code, std::string_view message)
anch::json::MappingError::prependField
void prependField(std::string_view field)
anch::json::MappingError::MappingError
MappingError(ErrorCode code, const anch::json::ReaderContext &context)
anch::json::ReaderContext
JSON reader context.
Definition
readerContext.hpp:44
anch::json
JSON namespace.
Definition
constants.hpp:27
anch::json::ErrorCode
ErrorCode
Definition
mappingError.hpp:43
anch::json::ErrorCode::POTENTIAL_OVERFLOW
@ POTENTIAL_OVERFLOW
Definition
mappingError.hpp:51
anch::json::ErrorCode::UNKNOWN
@ UNKNOWN
Definition
mappingError.hpp:72
anch::json::ErrorCode::PAYLOAD_TOO_LARGE
@ PAYLOAD_TOO_LARGE
Definition
mappingError.hpp:69
anch::json::ErrorCode::MISSING_FIELD
@ MISSING_FIELD
Definition
mappingError.hpp:57
anch::json::ErrorCode::UNEXPECTED_FIELD
@ UNEXPECTED_FIELD
Definition
mappingError.hpp:48
anch
AnCH framework base namespace.
Definition
app.hpp:30
anch-json
inc
json
mappingError.hpp
Generated by
1.18.0