errors 0.6.3
Loading...
Searching...
No Matches
errors::error Class Referenceabstract

Interface representing an error. More...

#include <errors/error.hpp>

Inheritance diagram for errors::error:
Collaboration diagram for errors::error:

Public Member Functions

virtual const char * what () const noexcept=0
 Get error message.
 
virtual const error_ptrcause () const &noexcept=0
 Get cause of this error, if any.
 
virtual error_ptr cause () &&noexcept=0
 Transfer the ownership of cause of this error, if any.
 
virtual std::optional< source_locationlocation () const noexcept=0
 Get the source location of this error, if any.
 
- Public Member Functions inherited from errors::detail::interface
 interface (const interface &)=delete
 
 interface (interface &&)=delete
 
interfaceoperator= (interface &&)=delete
 
interfaceoperator= (const interface &)=delete
 

Detailed Description

Interface representing an error.

This interface class represents an error with an optional source location where it was generated and an optional cause.

Member Function Documentation

◆ cause() [1/2]

virtual error_ptr errors::error::cause ( ) &&
nodiscardpure virtualnoexcept

Transfer the ownership of cause of this error, if any.

Returns
A smart pointer holds the cause of current error, or a nullptr if there is no cause

This method is used to transfer the ownership of the cause, use with caution.

Implemented in errors::impl::error_with_cause, and errors::impl::error_without_cause.

◆ cause() [2/2]

virtual const error_ptr & errors::error::cause ( ) const &
nodiscardpure virtualnoexcept

Get cause of this error, if any.

Returns
Reference to a smart pointer which holds the cause of current error, or a nullptr if there is no cause.

Implemented in errors::impl::error_with_cause, and errors::impl::error_without_cause.

◆ location()

virtual std::optional< source_location > errors::error::location ( ) const
nodiscardpure virtualnoexcept

Get the source location of this error, if any.

Returns
An optional source location.

This method returns the source location where this error is generated, if it is available.

Implemented in errors::impl::base_error.

◆ what()

virtual const char * errors::error::what ( ) const
nodiscardpure virtualnoexcept

Get error message.

Returns
A c-style string, which is an error message. It should never be NULL, but it can be an empty string.

This method works just like std::exception::what, you should print all the context which is useful for debugging in this method except for the source location.

Implemented in errors::impl::code_error< Code >, errors::impl::code_error< int >, errors::impl::exception_error, errors::impl::runtime_error, and errors::impl::wrap_error.


The documentation for this class was generated from the following file: