Blaze 0.0.1
The ultra high-performance JSON Schema evaluator
Loading...
Searching...
No Matches
convert_error.h
1#ifndef SOURCEMETA_BLAZE_CONVERT_ERROR_H_
2#define SOURCEMETA_BLAZE_CONVERT_ERROR_H_
3
4#ifndef SOURCEMETA_BLAZE_CONVERT_EXPORT
5#include <sourcemeta/blaze/convert_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_CONVERT_EXPORT ConvertUnsupportedDialectError
27 : public std::exception {
28public:
29 ConvertUnsupportedDialectError(const std::string_view identifier,
30 sourcemeta::core::Pointer location)
31 : identifier_{identifier}, location_{std::move(location)} {}
32
33 [[nodiscard]] auto what() const noexcept -> const char * override {
34 return "The conversion does not support this dialect";
35 }
36
37 [[nodiscard]] auto identifier() const noexcept -> std::string_view {
38 return this->identifier_;
39 }
40
41 [[nodiscard]] auto location() const noexcept
42 -> const sourcemeta::core::Pointer & {
43 return this->location_;
44 }
45
46private:
47 std::string identifier_;
48 sourcemeta::core::Pointer location_;
49};
50
53class SOURCEMETA_BLAZE_CONVERT_EXPORT ConvertUnsupportedMetaschemaError
54 : public std::exception {
55public:
56 ConvertUnsupportedMetaschemaError(const std::string_view identifier,
57 sourcemeta::core::Pointer location)
58 : identifier_{identifier}, location_{std::move(location)} {}
59
60 [[nodiscard]] auto what() const noexcept -> const char * override {
61 return "The conversion does not support meta-schemas";
62 }
63
64 [[nodiscard]] auto identifier() const noexcept -> std::string_view {
65 return this->identifier_;
66 }
67
68 [[nodiscard]] auto location() const noexcept
69 -> const sourcemeta::core::Pointer & {
70 return this->location_;
71 }
72
73private:
74 std::string identifier_;
75 sourcemeta::core::Pointer location_;
76};
77
80class SOURCEMETA_BLAZE_CONVERT_EXPORT ConvertInvalidReferenceError
81 : public std::exception {
82public:
83 ConvertInvalidReferenceError(const std::string_view identifier,
84 sourcemeta::core::Pointer location)
85 : identifier_{identifier}, location_{std::move(location)} {}
86
87 [[nodiscard]] auto what() const noexcept -> const char * override {
88 return "The reference does not point to a schema";
89 }
90
91 [[nodiscard]] auto identifier() const noexcept -> std::string_view {
92 return this->identifier_;
93 }
94
95 [[nodiscard]] auto location() const noexcept
96 -> const sourcemeta::core::Pointer & {
97 return this->location_;
98 }
99
100private:
101 std::string identifier_;
102 sourcemeta::core::Pointer location_;
103};
104
107class SOURCEMETA_BLAZE_CONVERT_EXPORT ConvertBrokenReferenceError
108 : public std::exception {
109public:
110 ConvertBrokenReferenceError(const std::string_view identifier,
111 sourcemeta::core::Pointer location)
112 : identifier_{identifier}, location_{std::move(location)} {}
113
114 [[nodiscard]] auto what() const noexcept -> const char * override {
115 return "The reference broke after transformation";
116 }
117
118 [[nodiscard]] auto identifier() const noexcept -> std::string_view {
119 return this->identifier_;
120 }
121
122 [[nodiscard]] auto location() const noexcept
123 -> const sourcemeta::core::Pointer & {
124 return this->location_;
125 }
126
127private:
128 std::string identifier_;
129 sourcemeta::core::Pointer location_;
130};
131
132#if defined(_MSC_VER)
133#pragma warning(default : 4251 4275)
134#endif
135
136} // namespace sourcemeta::blaze
137
138#endif