|
| template<typename... Args> |
| | CoriError (const std::string &message, Args &&... args) |
| | Constructs CoriError object and formats the final error message.
|
| | ~CoriError () override |
| | CoriError (const CoriError &other) noexcept |
| | CoriError (CoriError &&other) noexcept |
| CoriError & | operator= (const CoriError &other)=delete |
| CoriError & | operator= (CoriError &&other) noexcept=delete |
| const char * | what () const noexcept override |
| | Returns the formated message and if called the CoriError is considered 'seen'.
|
| void | Ignore () const |
| | Explicitly sets the CoriError object into 'seen' state.
|
| template<typename T> |
| T | Get () const |
| | Retrieves the value of the type requested from the CoriError object.
|
template<typename... Types>
requires (sizeof...(Types) > 1) |
| std::tuple< Types... > | Get () const |
| | The overload of Get method for use with structured bindings.
|
template<typename... DeclaredTypes>
class Cori::Core::CoriError< DeclaredTypes >
Custom error class mainly used in std::expected.
- Template Parameters
-
| DeclaredTypes | Types that will be obtainable. |
Can hold variables that are passed upon creation that are later obtainable via Get method, duplicate types are illegal. As it is derived from std::exception it can be thrown.
If a CoriError object was constructed and never 'seen' it will print the formated error message upon destruction.
DeclaredTypes typenames will be embedded into the formated error message alongside the user-defined description for each one, and if they are streamable their value will be embedded as well.
Example usage:
Example specialization: CoriError<int, std::type_index>
Constructed like this: CoriError<int, std::type_index>("Main error message", "user-defined description for int", intValue, "user-defined description for std::type_index", type_indexValue);
The final error message will be: Main error message | Additional data: (user-defined description for int (int): 'intValue', user-defined description for std::type_index (std::type_index): 'Type is not streamable, you can retrieve it with Get<T>()') |
Also all the types from DeclaredTypes can be later retried using Get<T>(), and it also supports retrieving multiple at a time and returning them in a tuple.
Definition at line 27 of file Error.hpp.