37#include <spdlog/spdlog.h>
39#include <pdi/pdi_fwd.h>
40#include <pdi/paraconf_wrapper.h>
47 = std::ranges::input_range<R> && std::ranges::sized_range<R> && std::convertible_to<std::ranges::range_reference_t<R>, std::exception_ptr>;
57class PDI_EXPORT
Error:
virtual public std::exception
84 template <typename... Args>
85 [[noreturn]]
void inline
rethrow_with_context(fmt::format_string<Args...> format_str, Args&&... args)
const
95class PDI_EXPORT what_impl:
virtual public std::exception
105 what_impl(std::string what)
noexcept;
108 const char* what() const noexcept override;
113class PDI_EXPORT status_impl: virtual public Error
116 PDI_status_t status() const noexcept
override {
return STATUS; }
120template <PDI_status_t STATUS>
121class PDI_EXPORT Error_impl
123 ,
public status_impl<STATUS>
129 Error_impl(std::string what)
noexcept;
135 template <
typename... Args>
136 inline Error_impl(fmt::format_string<Args...> format_str, Args&&... args) noexcept
137 : Error_impl(fmt::format(format_str, std::forward<Args>(args)...))
140 using what_impl::what;
142 using status_impl<STATUS>::status;
144 std::string full_msg()
const override;
146 [[noreturn]]
void rethrow_with_context(std::string msg)
const override;
154extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_VALUE>;
159extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_PLUGIN>;
164extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_IMPL>;
170extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_STATE>;
175extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_PERMISSION>;
180extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_SYSTEM>;
185extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_TYPE>;
190extern template class PDI_EXPORT impl::Error_impl<PDI_ERR_INVALIDACTION>;
194class PDI_EXPORT Spectree_error
195 :
public impl::what_impl
196 ,
public impl::status_impl<PDI_ERR_SPECTREE>
199 std::optional<Yaml_region> m_location;
201 Spectree_error(std::optional<Yaml_region> location, std::string what);
215 template <
typename... Args>
216 inline Spectree_error(PC_tree_t tree, fmt::format_string<Args...> format_str, Args&&... args)
217 : Spectree_error(tree, fmt::format(format_str,
std::forward<Args>(args)...))
220 using what_impl::what;
232 :
public impl::status_impl<PDI_ERR_MULTIPLE>
233 ,
public impl::what_impl
237 std::vector<std::exception_ptr> m_nested_ptrs;
251 template <
typename... Args>
253 :
Multiple_errors(std::vector<std::exception_ptr>(causes.begin(), causes.end()), fmt::format(format_str, std::forward<Args>(args)...))
261 using status_impl::status;
263 using what_impl::what;
283template <
typename... Args>
284[[noreturn]]
static inline void rethrow_with_context(std::exception_ptr err, fmt::format_string<Args...> format_str, Args&&... args)
310template <
typename... Args>
311static inline void rethrow_with_context(
range_of_exception_ptrs auto&& errors, fmt::format_string<Args...> format_str, Args&&... args)
313 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:58
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:252
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:216
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:47
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:174
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:189
impl::Error_impl< PDI_ERR_VALUE > Value_error
An error class to use when a value expression is invalid.
Definition error.h:153
impl::Error_impl< PDI_ERR_TYPE > Type_error
An error class to use for invalid types.
Definition error.h:184
impl::Error_impl< PDI_ERR_IMPL > Impl_error
An error class to use for implementation limitations (typically an unimplemented feature).
Definition error.h:163
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:169
impl::Error_impl< PDI_ERR_SYSTEM > System_error
An error class to use when a system error occurred (OS, etc.).
Definition error.h:179
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:158