Blaze 0.0.1
The ultra high-performance JSON Schema evaluator
Loading...
Searching...
No Matches
documentation_error.h
1#ifndef SOURCEMETA_BLAZE_DOCUMENTATION_ERROR_H_
2#define SOURCEMETA_BLAZE_DOCUMENTATION_ERROR_H_
3
4#ifndef SOURCEMETA_BLAZE_DOCUMENTATION_EXPORT
5#include <sourcemeta/blaze/documentation_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(push)
22#pragma warning(disable : 4251 4275)
23#endif
24
29class SOURCEMETA_BLAZE_DOCUMENTATION_EXPORT DocumentationError
30 : public std::exception {
31public:
35 DocumentationError(const char *message, sourcemeta::core::Pointer location,
36 std::string subject = "")
37 : message_{message}, location_{std::move(location)},
38 subject_{std::move(subject)} {}
39
40 [[nodiscard]] auto what() const noexcept -> const char * override {
41 return this->message_;
42 }
43
46 [[nodiscard]] auto subject() const noexcept -> std::string_view {
47 return this->subject_;
48 }
49
51 [[nodiscard]] auto location() const noexcept
52 -> const sourcemeta::core::Pointer & {
53 return this->location_;
54 }
55
56private:
57 const char *message_;
58 sourcemeta::core::Pointer location_;
59 std::string subject_;
60};
61
62#if defined(_MSC_VER)
63#pragma warning(pop)
64#endif
65
66} // namespace sourcemeta::blaze
67
68#endif
DocumentationError(const char *message, sourcemeta::core::Pointer location, std::string subject="")
Definition documentation_error.h:35
auto location() const noexcept -> const sourcemeta::core::Pointer &
Where in the schema the trouble is.
Definition documentation_error.h:51
auto subject() const noexcept -> std::string_view
Definition documentation_error.h:46