5 #include "config_origin.hpp" 6 #include <leatherman/locale/locale.hpp> 16 runtime_error(leatherman::locale::format(
"{1}: {2}", origin.
description(), message)) { }
19 config_exception(std::string
const& message, std::exception
const& e) : runtime_error(leatherman::locale::format(
"{1} {2}", message, e.what())) { }
29 std::string
const&
path, std::string
const& expected, std::string
const& actual) :
30 config_exception(origin, leatherman::locale::format(
"{1} has type {2} rather than {3}",
path, actual, expected)) { }
31 using config_exception::config_exception;
40 config_exception(leatherman::locale::format(
"No configuration setting found for key '{1}'",
path)) { }
41 using config_exception::config_exception;
50 missing_exception(origin, (expected.empty() ? leatherman::locale::format(
"Configuration key \"{1}\" is null",
path)
51 : leatherman::locale::format(
"Configuration key \"{1}\" is set to null but expected {2}",
path, expected))) { }
61 config_exception(origin, leatherman::locale::format(
"Invalid value at '{1}': {2}",
path, message)) { }
73 config_exception(origin,
path.empty() ? message : leatherman::locale::format(
"Invalid path '{1}': {2}",
path, message)) { }
112 parse_exception(origin, leatherman::locale::format(
"Could not resolve subtitution to a value: {1}", detail)) { }
138 path(std::move(path_)), origin(std::move(origin_)),
problem(std::move(problem_)) { }
140 const std::string
path;
141 const shared_origin origin;
144 std::string to_string() {
145 return leatherman::locale::format(
"ValidationProblem({1},{2},{3})",
path, origin->description(),
problem);
157 config_exception(make_message(problems_)), problems(std::move(problems_)) { }
159 const std::vector<validation_problem> problems;
162 static std::string make_message(std::vector<validation_problem>
const& problems_) {
164 for (
auto &p : problems_) {
165 auto sep = std::string(
": ");
166 for (
auto &s : {p.origin->description(), sep, p.path, sep, p.problem, std::string(
", ")}) {
171 throw bug_or_broken_exception(leatherman::locale::format(
"validation_failed_exception must have a non-empty list of problems"));
173 msg.resize(msg.length() - 2);
Exception indicates that the setting was treated as missing because it was set to null...
Exception indicating that there was an IO error.
Exception indicating that a substitution did not resolve to anything.
All exceptions thrown by the library are subclasses of config_exception.
Factory for creating config_document instances.
Exception indicating that there was a parse error.
Information about a problem that occurred in config#check_valid.
virtual LIBCPP_HOCON_EXPORT std::string const & description() const =0
Returns a string describing the origin of a value or exception.
Represents the origin (such as filename and line number) of a config_value for use in error messages...
Exception indicating that there's a bug in something (possibly the library itself) or the runtime env...
Exception indicating that you tried to use a function that requires substitutions to be resolved...
Exception that doesn't fall into any other category.
Exception indicating that a value was messed up, for example you may have asked for a duration and th...
Exception indicates that the setting was never set to anything, not even null.
Exception indicating that the type of a value does not match the type you requested.
Exception indicating that config#check_valid found validity problems.
Exception indicating that a path expression was invalid.