ImFusion SDK 4.3
ErrorInterface Class Referenceabstract

#include <RoboticsPlugin/Include/ImFusion/Robotics/Error.h>

An interface for error handling and representation. More...

+ Inheritance diagram for ErrorInterface:

Detailed Description

An interface for error handling and representation.

This interface defines a common interface for all error handling and representation types. Representation of various errors is done via the exposition additional properties: id, message, and domain.

  • id: A unique identifier for the error within its domain.
  • message: A human-readable description of the error.
  • domain: This property indicates the "category" or source of the error, disambiguating errors using the same id coming from different sources and allowing the tracking of errors back to their specific library or module. It identifies which specialization of the ErrorInterface the class is currently using.

Public Member Functions

virtual void handle ()
 Error handling strategy, allows the user to define a task on the constructor of ErrorFrontEnd.
 
virtual std::string domain () const =0
 Returns the category to which the custom error implementation belongs.
 
virtual int id () const =0
 Retrieves the unique identifier for the error.
 
virtual std::string message () const =0
 Retrieves the error message.
 
template<typename T>
 operator Utils::Expected< T, ErrorFrontEnd > () const &
 Template method for casting to std::expected<T, ErrorFrontEnd>.
 
std::unique_ptr< ErrorInterfaceclone () const &
 Creates a copy of the current instance.
 
bool operator== (const ErrorFrontEnd &other) const
 Compares the id and the domain.
 
bool operator== (const ErrorInterface &other) const
 Compares the id and the domain.
 
virtual ErrorComposition operator| (const ErrorInterface &input) const
 Composition operator.
 

Protected Member Functions

virtual ErrorInterfacecloneImpl () const =0
 Clone implementation, used to exploit covariant overriding on the return type to return a pointer to the implementation rather than the interface.
 

Member Function Documentation

◆ handle()

virtual void handle ( )
inlinevirtual

Error handling strategy, allows the user to define a task on the constructor of ErrorFrontEnd.

Reimplemented in ErrorKDL, and ErrorTracIK.

◆ domain()

virtual std::string domain ( ) const
nodiscardpure virtual

Returns the category to which the custom error implementation belongs.

Returns
string representing the category

Implemented in ErrorComposition, ErrorException, ErrorKDL, ErrorTracIK, Optimizer::Error, OptimizerNLopt::Error, RobotSolution, and SimpleErrorMessage.

◆ id()

virtual int id ( ) const
nodiscardpure virtual

Retrieves the unique identifier for the error.

Returns
The error ID.

Implemented in ErrorComposition, ErrorException, ErrorKDL, ErrorTracIK, Optimizer::Error, OptimizerNLopt::Error, RobotSolution, and SimpleErrorMessage.

◆ message()

virtual std::string message ( ) const
nodiscardpure virtual

Retrieves the error message.

This method is abstract to force the user to instantiate the error with the correct message.

Returns
An error message.

Implemented in ErrorComposition, ErrorException, ErrorKDL, ErrorTracIK, Optimizer::Error, OptimizerNLopt::Error, RobotSolution, and SimpleErrorMessage.

◆ operator Utils::Expected< T, ErrorFrontEnd >()

template<typename T>
operator Utils::Expected< T, ErrorFrontEnd > ( ) const &
inline

Template method for casting to std::expected<T, ErrorFrontEnd>.

Template Parameters
TThe type of the expected value.
Returns
A Utils::Expected<T, ErrorFrontEnd> containing either the value or the error.

◆ clone()

std::unique_ptr< ErrorInterface > clone ( ) const &
inlinenodiscard

Creates a copy of the current instance.

This method performs a deep copy of the current instance and returns a new dynamically allocated instance that is a clone of this object.

Returns
A unique pointer to the newly cloned instance.

◆ operator==() [1/2]

bool operator== ( const ErrorFrontEnd & other) const
inline

Compares the id and the domain.

Returns
true if two instances have the same id and domain

◆ operator==() [2/2]

bool operator== ( const ErrorInterface & other) const
inline

Compares the id and the domain.

Returns
true if two instances have the same id and domain

◆ operator|()

virtual ErrorComposition operator| ( const ErrorInterface & input) const
virtual

Composition operator.

This operator allows stacking errors to represent a causal relationship. The error passed as argument should have been caused by the errors contained in this composition.

Usage example:

class MyError: ErrorInheritanceHelper<MyError> { /* .. *&zwj;/ };
Expected<double> myFunction()
{
Expected<int> res1 = myOtherFunction();
if (!res1)
return res1.error() | MyError();
// ...
}
Auxiliary type intended to implement a user defined specialization of ErrorInterface.
Definition Error.h:230

Reimplemented in ErrorComposition.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close