38#include <spdlog/spdlog.h>
40#include <pdi/pdi_fwd.h>
41#include <pdi/paraconf_wrapper.h>
48 = std::ranges::input_range<R> && std::ranges::sized_range<R> && std::convertible_to<std::ranges::range_reference_t<R>, std::exception_ptr>;
58class PDI_EXPORT
Error:
virtual public std::exception
85 template <typename... Args>
86 [[noreturn]]
void inline
rethrow_with_context(fmt::format_string<Args...> format_str, Args&&... args)
const
96class PDI_EXPORT What_impl:
virtual public std::exception
106 What_impl(std::string what)
noexcept;
109 const char* what() const noexcept override;
114class PDI_EXPORT Status_impl: virtual public Error
117 PDI_status_t status() const noexcept
override {
return STATUS; }
121template <PDI_status_t STATUS>
122class PDI_EXPORT Error_impl
124 ,
public Status_impl<STATUS>
130 Error_impl(std::string what)
noexcept;
136 template <
typename... Args>
137 inline Error_impl(fmt::format_string<Args...> format_str, Args&&... args) noexcept
138 : Error_impl(fmt::format(format_str, std::forward<Args>(args)...))
141 using What_impl::what;
143 using Status_impl<STATUS>::status;
145 std::string full_msg()
const override;
147 [[noreturn]]
void rethrow_with_context(std::string msg)
const override;
155extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_VALUE>;
160extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_PLUGIN>;
165extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_IMPL>;
171extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_STATE>;
176extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_PERMISSION>;
181extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_SYSTEM>;
186extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_TYPE>;
191extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_INVALIDACTION>;
195class PDI_EXPORT Spectree_error
196 :
public impl::What_impl
197 ,
public impl::Status_impl<PDI_ERR_SPECTREE>
200 std::optional<Yaml_region> m_location;
202 Spectree_error(std::optional<Yaml_region> location, std::string what);
216 template <
typename... Args>
217 inline Spectree_error(PC_tree_t tree, fmt::format_string<Args...> format_str, Args&&... args)
218 : Spectree_error(tree, fmt::format(format_str,
std::forward<Args>(args)...))
221 using What_impl::what;
233 :
public impl::Status_impl<PDI_ERR_MULTIPLE>
234 ,
public impl::What_impl
238 std::vector<std::exception_ptr> m_nested_ptrs;
252 template <
typename... Args>
254 :
Multiple_errors(std::vector<std::exception_ptr>(causes.begin(), causes.end()), fmt::format(format_str, std::forward<Args>(args)...))
262 using Status_impl::status;
264 using What_impl::what;
284template <
typename... Args>
285[[noreturn]]
static inline void rethrow_with_context(std::exception_ptr err, fmt::format_string<Args...> format_str, Args&&... args)
311template <
typename... Args>
312static inline void rethrow_with_context(
range_of_exception_ptrs auto&& errors, fmt::format_string<Args...> format_str, Args&&... args)
314 rethrow_with_simple_context(std::vector<std::exception_ptr>(errors.begin(), errors.end()), fmt::format(format_str, std::forward<Args>(args)...));
An error class from which all PDI error are children.
Definition error.h:59
virtual std::string full_msg() const =0
Gives access to a full error message.
virtual PDI_status_t status() const noexcept=0
Gives access to the status of the error.
virtual ~Error() noexcept
virtual void rethrow_with_context(std::string context) const =0
Rethrow the error with some context prepended to its description.
std::vector< std::exception_ptr > const & nested_ptrs() const
Gives access to the list or original errors.
std::string full_msg() const override
Gives access to a full error message.
Multiple_errors(range_of_exception_ptrs auto &&causes, fmt::format_string< Args... > format_str, Args &&... args) noexcept
Creates a new Multiple_errors.
Definition error.h:253
Multiple_errors(std::vector< std::exception_ptr > causes, std::string what) noexcept
Creates a new Multiple_errors.
void rethrow_with_context(std::string msg) const override
Rethrow the error with some context prepended to its description.
std::string full_msg() const override
Gives access to a full error message.
void rethrow_with_context(std::string msg) const override
Rethrow the error with some context prepended to its description.
Spectree_error(PC_tree_t tree, fmt::format_string< Args... > format_str, Args &&... args)
Creates a new Spectree_error.
Definition error.h:217
Spectree_error(PC_tree_t tree, std::string what)
Creates a new Spectree_error.
A concept that represent a "range" (list) of errors, in any kind of storage.
Definition error.h:48
PDI_status_t
Error codes of PDI.
Definition pdi.h:80
Definition array_datatype.h:38
impl::Error_impl< PDI_ERR_PERMISSION > Permission_error
An error class to use when a conflict of ownership over a content has been raised.
Definition error.h:175
impl::Error_impl< PDI_ERR_INVALIDACTION > Invalid_action_error
An error class to use when an action described in the specification tree is invalid.
Definition error.h:190
impl::Error_impl< PDI_ERR_VALUE > Value_error
An error class to use when a value expression is invalid.
Definition error.h:154
impl::Error_impl< PDI_ERR_TYPE > Type_error
An error class to use for invalid types.
Definition error.h:185
impl::Error_impl< PDI_ERR_IMPL > Impl_error
An error class to use for implementation limitations (typically an unimplemented feature).
Definition error.h:164
impl::Error_impl< PDI_ERR_STATE > State_error
An error class to use when a call to a function has been made at a wrong time (e.g.
Definition error.h:170
impl::Error_impl< PDI_ERR_SYSTEM > System_error
An error class to use when a system error occurred (OS, etc.).
Definition error.h:180
void rethrow_with_simple_context(std::exception_ptr err, std::string msg)
Throws a new exception by adding context to an existing exception.
impl::Error_impl< PDI_ERR_PLUGIN > Plugin_error
An error class to use when trying to load a non-existing plugin.
Definition error.h:159