15#if TOML_DOXYGEN || !TOML_EXCEPTIONS
16#define TOML_PARSE_ERROR_BASE
18#define TOML_PARSE_ERROR_BASE : public std::runtime_error
43 : std::runtime_error{ desc },
44 source_{ std::move(src) }
49 parse_error(
const char* desc,
const source_region& src)
noexcept
63 : description_{ std::move(desc) },
64 source_{ std::move(src) }
85 return std::string_view{ what() };
122 friend std::ostream&
operator<<(std::ostream& lhs,
const parse_error& rhs)
124 impl::print_to_stream(lhs, rhs.description());
125 impl::print_to_stream(lhs,
"\n\t(error occurred at "sv);
126 impl::print_to_stream(lhs, rhs.source());
127 impl::print_to_stream(lhs,
")"sv);
136#undef TOML_PARSE_ERROR_BASE
An error generated when parsing fails.
Definition parse_error.hpp:30
TOML_NODISCARD_CTOR parse_error(std::string &&desc, source_region &&src) noexcept
Definition parse_error.hpp:62
TOML_NODISCARD_CTOR parse_error(std::string &&desc, const source_region &src) noexcept
Definition parse_error.hpp:68
friend std::ostream & operator<<(std::ostream &lhs, const parse_error &rhs)
Prints a parse_error to a stream.
Definition parse_error.hpp:122
std::string description_
Definition parse_error.hpp:33
TOML_NODISCARD const source_region & source() const noexcept
Returns the region of the source document responsible for the error.
Definition parse_error.hpp:93
TOML_NODISCARD_CTOR parse_error(std::string &&desc, const source_position &position, const source_path_ptr &path={}) noexcept
Definition parse_error.hpp:73
TOML_NODISCARD std::string_view description() const noexcept
Returns a textual description of the error.
Definition parse_error.hpp:82
source_region source_
Definition parse_error.hpp:35
A TOML path.
Definition path.hpp:239
#define TOML_EXCEPTIONS
Sets whether the library uses exceptions to report parsing failures. \detail Defaults to 1 or 0 accor...
Definition preprocessor.hpp:1126
TOML_NAMESPACE_START
Definition parse_error.hpp:22
TOML_ABI_NAMESPACE_END
Definition parse_error.hpp:132
TOML_NAMESPACE_END
Definition parse_error.hpp:134
#define TOML_NODISCARD_CTOR
Definition preprocessor.hpp:446
#define TOML_ABI_NAMESPACE_BOOL(cond, T, F)
Definition preprocessor.hpp:1323
#define TOML_NODISCARD
Definition preprocessor.hpp:439
#define TOML_ATTR(...)
Definition preprocessor.hpp:316
std::shared_ptr< const std::string > source_path_ptr
A pointer to a shared string resource containing a source path.
Definition source_region.hpp:19
A source document line-and-column pair.
Definition source_region.hpp:43
A source document region.
Definition source_region.hpp:167