Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
jsonpath_error.h
1#ifndef SOURCEMETA_CORE_JSONPATH_ERROR_H_
2#define SOURCEMETA_CORE_JSONPATH_ERROR_H_
3
4#ifndef SOURCEMETA_CORE_JSONPATH_EXPORT
5#include <sourcemeta/core/jsonpath_export.h>
6#endif
7
8#include <cstdint> // std::uint64_t
9#include <exception> // std::exception
10
11namespace sourcemeta::core {
12
13// Exporting symbols that depends on the standard C++ library is considered
14// safe.
15// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
16#if defined(_MSC_VER)
17#pragma warning(disable : 4251 4275)
18#endif
19
22class SOURCEMETA_CORE_JSONPATH_EXPORT JSONPathParseError
23 : public std::exception {
24public:
26 JSONPathParseError(const std::uint64_t column) : column_{column} {}
27
28 [[nodiscard]] auto what() const noexcept -> const char * override {
29 return "The input is not a valid JSON Path query";
30 }
31
33 [[nodiscard]] auto column() const noexcept -> std::uint64_t {
34 return this->column_;
35 }
36
37private:
38 std::uint64_t column_;
39};
40
41#if defined(_MSC_VER)
42#pragma warning(default : 4251 4275)
43#endif
44
45} // namespace sourcemeta::core
46
47#endif
auto column() const noexcept -> std::uint64_t
Get the column number of the error.
Definition jsonpath_error.h:33
JSONPathParseError(const std::uint64_t column)
Construct an error given the column number where parsing failed.
Definition jsonpath_error.h:26