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>
8#include <sourcemeta/core/error.h>
14namespace sourcemeta::core {
16SOURCEMETA_CORE_ERROR_WARNINGS_PUSH
24 :
Error{
"Failed to parse the JSON document"}, line_{line},
29 const std::uint64_t
column) noexcept
33 [[nodiscard]]
auto line() const noexcept -> std::uint64_t {
38 [[nodiscard]]
auto column() const noexcept -> std::uint64_t {
44 std::uint64_t column_;
53 const std::uint64_t
line,
const std::uint64_t
column)
59 path_{std::move(
path)} {}
62 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
67 std::filesystem::path path_;
73class SOURCEMETA_CORE_JSON_EXPORT JSONNonFiniteError :
public Error {
75 JSONNonFiniteError() noexcept
76 :
Error{
"JSON does not support Infinity or NaN"} {}
88SOURCEMETA_CORE_ERROR_WARNINGS_POP
auto message() const noexcept -> StaticString
Definition error_base.h:78
Error(const StaticString message) noexcept
Construct the error given its message.
Definition error_base.h:84
auto column() const noexcept -> std::uint64_t
Get the column number of the error.
Definition json_error.h:38
JSONIntegerRangeError(const StaticString message) noexcept
Construct an error with the given message.
Definition json_error.h:85
auto line() const noexcept -> std::uint64_t
Get the line number of the error.
Definition json_error.h:33
JSONFileParseError(const StaticString message, std::filesystem::path path, const std::uint64_t line, const std::uint64_t column)
Create a file parsing error.
Definition json_error.h:52
auto path() const noexcept -> const std::filesystem::path &
Get the file path of the error.
Definition json_error.h:62
JSONParseError(const std::uint64_t line, const std::uint64_t column) noexcept
Create a parsing error.
Definition json_error.h:23
JSONParseError(const StaticString message, const std::uint64_t line, const std::uint64_t column) noexcept
Create a parsing error with a custom message.
Definition json_error.h:28
JSONFileParseError(std::filesystem::path path, const JSONParseError &parent)
Create a file parsing error from a parse error.
Definition json_error.h:57
Definition text_static_string.h:20