Blaze 0.0.1
The ultra high-performance JSON Schema evaluator
Loading...
Searching...
No Matches
test_error.h
1#ifndef SOURCEMETA_BLAZE_TEST_ERROR_H_
2#define SOURCEMETA_BLAZE_TEST_ERROR_H_
3
4#ifndef SOURCEMETA_BLAZE_TEST_EXPORT
5#include <sourcemeta/blaze/test_export.h>
6#endif
7
8#include <sourcemeta/core/jsonpointer.h>
9
10#include <cstdint> // std::uint64_t
11#include <exception> // std::exception
12#include <string> // std::string
13#include <string_view> // std::string_view
14#include <utility> // std::move
15
16namespace sourcemeta::blaze {
17
18// Exporting symbols that depends on the standard C++ library is considered
19// safe.
20// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
21#if defined(_MSC_VER)
22#pragma warning(disable : 4251 4275)
23#endif
24
27class SOURCEMETA_BLAZE_TEST_EXPORT TestParseError : public std::exception {
28public:
29 TestParseError(const char *message, sourcemeta::core::Pointer location,
30 std::uint64_t line, std::uint64_t column)
31 : message_{message}, location_{std::move(location)}, line_{line},
32 column_{column} {}
33 TestParseError(std::string message, sourcemeta::core::Pointer location,
34 std::uint64_t line, std::uint64_t column) = delete;
35 TestParseError(std::string &&message, sourcemeta::core::Pointer location,
36 std::uint64_t line, std::uint64_t column) = delete;
37 TestParseError(std::string_view message, sourcemeta::core::Pointer location,
38 std::uint64_t line, std::uint64_t column) = delete;
39
40 [[nodiscard]] auto what() const noexcept -> const char * override {
41 return this->message_;
42 }
43
44 [[nodiscard]] auto location() const noexcept
45 -> const sourcemeta::core::Pointer & {
46 return this->location_;
47 }
48
49 [[nodiscard]] auto line() const noexcept -> std::uint64_t {
50 return this->line_;
51 }
52
53 [[nodiscard]] auto column() const noexcept -> std::uint64_t {
54 return this->column_;
55 }
56
57private:
58 const char *message_;
59 sourcemeta::core::Pointer location_;
60 std::uint64_t line_;
61 std::uint64_t column_;
62};
63
64#if defined(_MSC_VER)
65#pragma warning(default : 4251 4275)
66#endif
67
68} // namespace sourcemeta::blaze
69
70#endif