1#ifndef SOURCEMETA_CORE_JSONSCHEMA_ERROR_H
2#define SOURCEMETA_CORE_JSONSCHEMA_ERROR_H
4#ifndef SOURCEMETA_CORE_JSONSCHEMA_EXPORT
5#include <sourcemeta/core/jsonschema_export.h>
8#include <sourcemeta/core/jsonpointer.h>
15namespace sourcemeta::core {
21#pragma warning(disable : 4251 4275)
26class SOURCEMETA_CORE_JSONSCHEMA_EXPORT
SchemaError :
public std::exception {
34 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
35 return this->message_;
45 :
public std::exception {
49 : identifier_{
identifier}, message_{message} {}
51 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
52 return this->message_;
56 [[nodiscard]]
auto identifier() const noexcept -> std::string_view {
57 return this->identifier_;
61 std::string identifier_;
75 "Relative meta-schema URIs are not valid "
76 "according to the JSON Schema specification"} {}
82 :
public std::exception {
86 : uri_{
uri}, message_{message} {}
88 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
89 return this->message_;
93 [[nodiscard]]
auto uri() const noexcept -> std::string_view {
105 :
public std::exception {
111 : identifier_{
identifier}, schema_location_{std::move(schema_location)},
114 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
115 return this->message_;
119 [[nodiscard]]
auto identifier() const noexcept -> std::string_view {
120 return this->identifier_;
126 -> const sourcemeta::core::
Pointer & {
127 return this->schema_location_;
131 std::string identifier_;
133 const char *message_;
138class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaUnknownDialectError
139 :
public std::exception {
141 SchemaUnknownDialectError() =
default;
143 [[nodiscard]]
auto what()
const noexcept ->
const char *
override {
144 return "Could not determine the dialect of the schema";
151class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaUnknownBaseDialectError
152 :
public std::exception {
154 SchemaUnknownBaseDialectError() =
default;
156 [[nodiscard]]
auto what()
const noexcept ->
const char *
override {
157 return "Could not determine the base dialect of the schema";
165 :
public std::exception {
171 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
172 return "A schema with a top-level `$ref` in JSON Schema Draft 7 and older "
173 "dialects ignores every sibling keywords (like identifiers and "
174 "meta-schema declarations) and therefore many operations, like "
175 "bundling, are not possible without undefined behavior";
179 [[nodiscard]]
auto identifier() const noexcept -> std::string_view {
180 return this->identifier_;
184 std::string identifier_;
190 :
public std::exception {
194 const std::string_view
value,
const char *message)
195 : keyword_{
keyword}, value_{
value}, message_{message} {}
197 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
198 return this->message_;
202 [[nodiscard]]
auto value() const noexcept -> std::string_view {
207 [[nodiscard]]
auto keyword() const noexcept -> std::string_view {
208 return this->keyword_;
212 std::string keyword_;
214 const char *message_;
220 :
public std::exception {
224 : identifier_{
identifier}, message_{message} {}
226 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
227 return this->message_;
231 [[nodiscard]]
auto identifier() const noexcept -> std::string_view {
232 return this->identifier_;
236 std::string identifier_;
237 const char *message_;
244 :
public std::exception {
249 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
250 return "The schema exceeds the maximum number of frame locations";
254 [[nodiscard]]
auto limit() const noexcept -> std::uint64_t {
259 std::uint64_t limit_;
265 :
public std::exception {
272 other_(std::move(
other)) {}
274 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
275 return "Schema anchor already exists";
279 [[nodiscard]]
auto identifier() const noexcept -> std::string_view {
280 return this->identifier_;
286 -> const sourcemeta::core::
Pointer & {
287 return this->location_;
291 [[nodiscard]]
auto other() const noexcept
292 -> const sourcemeta::core::
Pointer & {
297 std::string identifier_;
303#pragma warning(default : 4251 4275)
GenericPointer< JSON::String, PropertyHashJSON< JSON::String > > Pointer
Definition jsonpointer.h:39
auto uri() const noexcept -> std::string_view
The vocabulary that caused the error.
Definition jsonschema_error.h:93
SchemaKeywordError(const std::string_view keyword, const std::string_view value, const char *message)
Create a keyword error.
Definition jsonschema_error.h:193
SchemaVocabularyError(const std::string_view uri, const char *message)
Create a vocabulary error.
Definition jsonschema_error.h:85
auto limit() const noexcept -> std::uint64_t
The maximum number of locations that framing was allowed to register.
Definition jsonschema_error.h:254
auto identifier() const noexcept -> std::string_view
The anchor that collided.
Definition jsonschema_error.h:279
SchemaRelativeMetaschemaResolutionError(const std::string_view identifier)
Create a relative meta-schema resolution error.
Definition jsonschema_error.h:73
SchemaFrameError(const std::string_view identifier, const char *message)
Create a framing error.
Definition jsonschema_error.h:223
SchemaError(const char *message)
Create a general schema error.
Definition jsonschema_error.h:29
auto keyword() const noexcept -> std::string_view
The keyword that caused the error.
Definition jsonschema_error.h:207
auto value() const noexcept -> std::string_view
The value that caused the error.
Definition jsonschema_error.h:202
SchemaFrameLimitError(const std::uint64_t limit)
Create a framing limit error.
Definition jsonschema_error.h:247
SchemaReferenceObjectResourceError(const std::string_view identifier)
Create a reference object resource error.
Definition jsonschema_error.h:168
auto identifier() const noexcept -> std::string_view
The reference that caused the error.
Definition jsonschema_error.h:179
SchemaResolutionError(const std::string_view identifier, const char *message)
Create a schema resolution error.
Definition jsonschema_error.h:48
SchemaReferenceError(const std::string_view identifier, sourcemeta::core::Pointer schema_location, const char *message)
Create a reference error.
Definition jsonschema_error.h:108
auto location() const noexcept -> const sourcemeta::core::Pointer &
Definition jsonschema_error.h:285
auto identifier() const noexcept -> std::string_view
The identifier of the schema that caused the error.
Definition jsonschema_error.h:231
auto location() const noexcept -> const sourcemeta::core::Pointer &
Definition jsonschema_error.h:125
auto other() const noexcept -> const sourcemeta::core::Pointer &
The other place that declares the same anchor.
Definition jsonschema_error.h:291
auto identifier() const noexcept -> std::string_view
The identifier that could not be resolved.
Definition jsonschema_error.h:56
auto identifier() const noexcept -> std::string_view
The reference that caused the error.
Definition jsonschema_error.h:119
SchemaAnchorCollisionError(const std::string_view identifier, sourcemeta::core::Pointer location, sourcemeta::core::Pointer other)
Create an anchor collision error.
Definition jsonschema_error.h:268