1#ifndef SOURCEMETA_CORE_JSON_ERROR_H_
2#define SOURCEMETA_CORE_JSON_ERROR_H_
4#ifndef SOURCEMETA_CORE_JSON_EXPORT
5#include <sourcemeta/core/json_export.h>
15namespace sourcemeta::core {
21#pragma warning(disable : 4251 4275)
31 message_{
"Failed to parse the JSON document"} {}
36 : line_{
line}, column_{
column}, message_{message} {}
37 JSONParseError(
const std::uint64_t line,
const std::uint64_t column,
38 std::string message) =
delete;
39 JSONParseError(
const std::uint64_t line,
const std::uint64_t column,
40 std::string &&message) =
delete;
41 JSONParseError(
const std::uint64_t line,
const std::uint64_t column,
42 std::string_view message) =
delete;
44 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
45 return this->message_;
49 [[nodiscard]]
auto line() const noexcept -> std::uint64_t {
54 [[nodiscard]]
auto column() const noexcept -> std::uint64_t {
60 std::uint64_t column_;
70 const std::uint64_t
column,
const char *message)
73 const std::uint64_t column, std::string message) =
delete;
75 const std::uint64_t column,
76 std::string &&message) =
delete;
78 const std::uint64_t column,
79 std::string_view message) =
delete;
84 path_{std::move(
path)} {}
87 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
92 std::filesystem::path path_;
96#pragma warning(default : 4251 4275)
auto column() const noexcept -> std::uint64_t
Get the column number of the error.
Definition json_error.h:54
auto line() const noexcept -> std::uint64_t
Get the line number of the error.
Definition json_error.h:49
auto path() const noexcept -> const std::filesystem::path &
Get the file path of the error.
Definition json_error.h:87
JSONParseError(const std::uint64_t line, const std::uint64_t column, const char *message)
Create a parsing error with a custom error.
Definition json_error.h:34
JSONFileParseError(std::filesystem::path path, const JSONParseError &parent)
Create a file parsing error from a parse error.
Definition json_error.h:82
JSONParseError(const std::uint64_t line, const std::uint64_t column)
Create a parsing error.
Definition json_error.h:29
JSONFileParseError(std::filesystem::path path, const std::uint64_t line, const std::uint64_t column, const char *message)
Create a file parsing error.
Definition json_error.h:69