Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
openapi_error.h
1#ifndef SOURCEMETA_CORE_OPENAPI_ERROR_H_
2#define SOURCEMETA_CORE_OPENAPI_ERROR_H_
3
4#ifndef SOURCEMETA_CORE_OPENAPI_EXPORT
5#include <sourcemeta/core/openapi_export.h>
6#endif
7
8#include <sourcemeta/core/error.h>
9#include <sourcemeta/core/json.h>
10#include <sourcemeta/core/jsonpointer.h>
11
12#include <cstdint> // std::uint64_t
13#include <utility> // std::move
14
15namespace sourcemeta::core {
16
17SOURCEMETA_CORE_ERROR_WARNINGS_PUSH
18
32class SOURCEMETA_CORE_OPENAPI_EXPORT OpenAPIError : public Error {
33public:
36 : Error{message}, location_{std::move(location)} {}
37
41 : Error{message}, base_{std::move(base)}, location_{std::move(location)} {
42 }
43
46 [[nodiscard]] auto location() const noexcept -> const Pointer & {
47 return this->location_;
48 }
49
52 [[nodiscard]] auto base() const noexcept -> JSON::StringView {
53 return this->base_;
54 }
55
56private:
57 JSON::String base_;
58 Pointer location_;
59};
60
75class SOURCEMETA_CORE_OPENAPI_EXPORT OpenAPIResolutionError : public Error {
76public:
81 : Error{message}, base_{std::move(base)}, location_{std::move(location)},
82 identifier_{std::move(identifier)} {}
83
85 [[nodiscard]] auto identifier() const noexcept -> JSON::StringView {
86 return this->identifier_;
87 }
88
91 [[nodiscard]] auto location() const noexcept -> const Pointer & {
92 return this->location_;
93 }
94
96 [[nodiscard]] auto base() const noexcept -> JSON::StringView {
97 return this->base_;
98 }
99
100private:
101 JSON::String base_;
102 Pointer location_;
103 JSON::String identifier_;
104};
105
121class SOURCEMETA_CORE_OPENAPI_EXPORT OpenAPIReferenceError : public Error {
122public:
127 : Error{message}, base_{std::move(base)}, location_{std::move(location)},
128 identifier_{std::move(identifier)} {}
129
131 [[nodiscard]] auto identifier() const noexcept -> JSON::StringView {
132 return this->identifier_;
133 }
134
137 [[nodiscard]] auto location() const noexcept -> const Pointer & {
138 return this->location_;
139 }
140
142 [[nodiscard]] auto base() const noexcept -> JSON::StringView {
143 return this->base_;
144 }
145
146private:
147 JSON::String base_;
148 Pointer location_;
149 JSON::String identifier_;
150};
151
163class SOURCEMETA_CORE_OPENAPI_EXPORT OpenAPIFrameLimitError : public Error {
164public:
166 OpenAPIFrameLimitError(const std::uint64_t limit) noexcept
167 : Error{"The OpenAPI Description exceeds the maximum number of "
168 "locations that framing may register"},
169 limit_{limit} {}
170
172 [[nodiscard]] auto limit() const noexcept -> std::uint64_t {
173 return this->limit_;
174 }
175
176private:
177 std::uint64_t limit_;
178};
179
191class SOURCEMETA_CORE_OPENAPI_EXPORT OpenAPIBundleLimitError : public Error {
192public:
194 OpenAPIBundleLimitError(const std::uint64_t limit) noexcept
195 : Error{"The OpenAPI Description exceeds the maximum number of "
196 "locations that bundling may analyse"},
197 limit_{limit} {}
198
200 [[nodiscard]] auto limit() const noexcept -> std::uint64_t {
201 return this->limit_;
202 }
203
204private:
205 std::uint64_t limit_;
206};
207
208SOURCEMETA_CORE_ERROR_WARNINGS_POP
209
210} // namespace sourcemeta::core
211
212#endif
auto message() const noexcept -> StaticString
Definition error_base.h:78
Error(const StaticString message) noexcept
Construct the error given its message.
Definition error_base.h:84
std::basic_string< Char, CharTraits, Allocator< Char > > String
The string type used by the JSON document.
Definition json_value.h:52
Definition json_value.h:39
GenericPointer< JSON::String, PropertyHashJSON< JSON::String > > Pointer
Definition jsonpointer.h:41
auto location() const noexcept -> const Pointer &
Definition openapi_error.h:46
auto base() const noexcept -> JSON::StringView
Definition openapi_error.h:52
OpenAPIBundleLimitError(const std::uint64_t limit) noexcept
Create a bundling limit error.
Definition openapi_error.h:194
OpenAPIFrameLimitError(const std::uint64_t limit) noexcept
Create a framing limit error.
Definition openapi_error.h:166
auto identifier() const noexcept -> JSON::StringView
The URI that nothing could produce a document for.
Definition openapi_error.h:85
OpenAPIError(const StaticString message, JSON::String base, Pointer location)
Definition openapi_error.h:40
auto base() const noexcept -> JSON::StringView
Get the base URI of the document that makes the reference.
Definition openapi_error.h:142
auto limit() const noexcept -> std::uint64_t
The maximum number of locations that framing was allowed to register.
Definition openapi_error.h:172
auto base() const noexcept -> JSON::StringView
Get the base URI of the document that makes the reference.
Definition openapi_error.h:96
auto location() const noexcept -> const Pointer &
Definition openapi_error.h:137
auto limit() const noexcept -> std::uint64_t
The maximum number of locations that bundling was allowed to register.
Definition openapi_error.h:200
auto location() const noexcept -> const Pointer &
Definition openapi_error.h:91
OpenAPIError(const StaticString message, Pointer location)
Construct an error from a message and where the problem is.
Definition openapi_error.h:35
auto identifier() const noexcept -> JSON::StringView
The URI that the reference names, resolved and canonicalised.
Definition openapi_error.h:131
OpenAPIReferenceError(const StaticString message, JSON::String base, Pointer location, JSON::String identifier)
Definition openapi_error.h:125
OpenAPIResolutionError(const StaticString message, JSON::String base, Pointer location, JSON::String identifier)
Definition openapi_error.h:79
Definition text_static_string.h:20