Blaze 0.0.1
The ultra high-performance JSON Schema evaluator
 
Loading...
Searching...
No Matches
frame_error.h
1#ifndef SOURCEMETA_BLAZE_FRAME_ERROR_H
2#define SOURCEMETA_BLAZE_FRAME_ERROR_H
3
4#ifndef SOURCEMETA_BLAZE_FRAME_EXPORT
5#include <sourcemeta/blaze/frame_export.h>
6#endif
7
8#include <sourcemeta/core/jsonpointer.h>
9
10#include <exception> // std::exception
11#include <string> // std::string
12#include <string_view> // std::string_view
13#include <utility> // std::move
14
15namespace sourcemeta::blaze {
16
17// Exporting symbols that depends on the standard C++ library is considered
18// safe.
19// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
20#if defined(_MSC_VER)
21#pragma warning(disable : 4251 4275)
22#endif
23
26class SOURCEMETA_BLAZE_FRAME_EXPORT SchemaFrameError : public std::exception {
27public:
28 SchemaFrameError(const std::string_view identifier, const char *message)
29 : identifier_{identifier}, message_{message} {}
30
31 [[nodiscard]] auto what() const noexcept -> const char * override {
32 return this->message_;
33 }
34
35 [[nodiscard]] auto identifier() const noexcept -> std::string_view {
36 return this->identifier_;
37 }
38
39private:
40 std::string identifier_;
41 const char *message_;
42};
43
46class SOURCEMETA_BLAZE_FRAME_EXPORT SchemaAnchorCollisionError
47 : public std::exception {
48public:
49 SchemaAnchorCollisionError(const std::string_view identifier,
50 sourcemeta::core::Pointer location,
51 sourcemeta::core::Pointer other)
52 : identifier_{identifier}, location_(std::move(location)),
53 other_(std::move(other)) {}
54
55 [[nodiscard]] auto what() const noexcept -> const char * override {
56 return "Schema anchor already exists";
57 }
58
59 [[nodiscard]] auto identifier() const noexcept -> std::string_view {
60 return this->identifier_;
61 }
62
63 [[nodiscard]] auto location() const noexcept
64 -> const sourcemeta::core::Pointer & {
65 return this->location_;
66 }
67
68 [[nodiscard]] auto other() const noexcept
69 -> const sourcemeta::core::Pointer & {
70 return this->other_;
71 }
72
73private:
74 std::string identifier_;
75 sourcemeta::core::Pointer location_;
76 sourcemeta::core::Pointer other_;
77};
78
79#if defined(_MSC_VER)
80#pragma warning(default : 4251 4275)
81#endif
82
83} // namespace sourcemeta::blaze
84
85#endif
Definition frame_error.h:26