Pecunia 0.9.0-alpha.22
Library using the ISO-4217 currency standard & a fixed monetary unit size
Loading...
Searching...
No Matches
pecunia::Error Class Reference

A representation of a generalised software issue, complete with the location of the problem. More...

#include <Errors.hpp>

Inheritance diagram for pecunia::Error:
Collaboration diagram for pecunia::Error:

Public Member Functions

 Error () noexcept
 
 Error (const Error &other) noexcept
 Constructs a copy of an existing instance.
 
 Error (const std::string &message, const std::exception &original) noexcept
 Constructs an Error object with a synthesised message combining the provided message, and the error message output of the supplied original exception.
 
 Error (Error &&other) noexcept
 Constructs an object by transferring ownership of resources from another object.
 
 Error (std::string message) noexcept
 Message constructor that initialises with a supplied message and captures the backtrace for diagnostic purposes.
 
 ~Error () noexcept override
 Safely destroys the object, ensuring any allocated resources are properly freed.
 
std::vector< std::string > frameStack () const noexcept
 Retrieves the stack frames associated with this instance.
 
Erroroperator= (const Error &other) noexcept
 Assigns the state of the given instance to this instance.
 
Erroroperator= (Error &&other) noexcept
 Assigns the given object to the current instance, transferring ownership of resources if any.
 
const char * what () const noexcept override
 Retrieves the human-readable description of the error. It is commonly used for logging or display purposes.
 

Detailed Description

A representation of a generalised software issue, complete with the location of the problem.

Constructor & Destructor Documentation

◆ Error() [1/5]

pecunia::Error::Error ( )
noexcept

Default constructor that initialises with a default message and captures the stack trace.

◆ Error() [2/5]

pecunia::Error::Error ( std::string message)
explicitnoexcept

Message constructor that initialises with a supplied message and captures the backtrace for diagnostic purposes.

Parameters
messageThe details providing context about the error to be described in the instance.

◆ Error() [3/5]

pecunia::Error::Error ( const std::string & message,
const std::exception & original )
noexcept

Constructs an Error object with a synthesised message combining the provided message, and the error message output of the supplied original exception.

Parameters
messageThe details providing context about the error to be described in the instance.
originalThe original exception that caused this Error, used to extract additional information.

◆ Error() [4/5]

pecunia::Error::Error ( const Error & other)
noexcept

Constructs a copy of an existing instance.

It performs a deep copy of the internals, ensuring uniqueness of resources between the original and the copy.

Parameters
otherThe other instance to copy from.
Postcondition
The newly constructed object will have the same message and trace information as the original other instance.

◆ Error() [5/5]

pecunia::Error::Error ( Error && other)
noexcept

Constructs an object by transferring ownership of resources from another object.

This constructor is used to create a new instance, taking over the existing data and state of another object.

Parameters
otherThe other object whose resources will be moved to the newly created object.
Postcondition
The newly created object contains the previous state of the other object. The other object is left in a valid, but unspecified state.

◆ ~Error()

pecunia::Error::~Error ( )
overridenoexcept

Safely destroys the object, ensuring any allocated resources are properly freed.

Member Function Documentation

◆ frameStack()

std::vector< std::string > pecunia::Error::frameStack ( ) const
nodiscardnoexcept

Retrieves the stack frames associated with this instance.

This is used to obtain a backtrace of stack frames that can help in identifying where the error occurred. It generates a detailed trace based on the error’s internal state.

Returns
A vector of strings representing the sequence of stack frames of the error’s backtrace. The specific formatting is dependent upon the compiler, but the error’s constructor will /not/ be a part of the trace.
Note
The trace is generated on demand, and is not cached.

◆ operator=() [1/2]

Error & pecunia::Error::operator= ( const Error & other)
noexcept

Assigns the state of the given instance to this instance.

This method ensures that all internal states of the current object are replaced by the corresponding states from the other object. The method aims to establish functional equality between the current instance, and the other instance.

Parameters
otherThe instance whose state will be copied to the current object.
Postcondition
The current instance will contain the same state as the other instance.
Returns
A reference to the current instance, reflecting the updated state.

◆ operator=() [2/2]

Error & pecunia::Error::operator= ( Error && other)
noexcept

Assigns the given object to the current instance, transferring ownership of resources if any.

Parameters
otherThe object that will be assigned to the current instance.
Postcondition
The current instance will contain the data or configuration of the other object.
The “other” object will be left in a valid but unspecified state.
Returns
The current instance after the assignment.

◆ what()

const char * pecunia::Error::what ( ) const
nodiscardoverridenoexcept

Retrieves the human-readable description of the error. It is commonly used for logging or display purposes.

Returns
The error’s message, which may provide insight into what caused the error.