StormByte 2.0.0
C++26 foundation of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Exception Class Reference

Base exception type for the suite. More...

#include <StormByte/exception.hxx>

Inheritance diagram for StormByte::Exception:

Classes

struct  Path
 Segments under StormByte, already joined with a dot. More...
 

Public Member Functions

 Exception (const std::string &message)
 Constructs from a string.
 
 Exception (std::string &&message)
 Constructs from a moved string.
 
template<typename... Args>
 Exception (std::format_string< Args... > fmt, Args &&... args)
 Constructs with std::format.
 
 Exception (const Exception &e)=default
 Copy constructor.
 
 Exception (Exception &&e) noexcept=default
 Move constructor.
 
virtual ~Exception () noexcept
 Destructor.
 
Exception & operator= (const Exception &e)=default
 Copy assignment.
 
Exception & operator= (Exception &&e) noexcept=default
 Move assignment.
 
virtual const char * what () const noexcept
 Message pointer.
 

Protected Member Functions

template<typename... Args>
 Exception (Path path, std::format_string< Args... > fmt, Args &&... args)
 Stores StormByte.path: message, or StormByte: message when path is empty.
 

Detailed Description

Base exception type for the suite.

what() is StormByte: message, or StormByte.path: message when a module parent passes the segments under StormByte (Crypto.Crypter). Segments are joined with a dot. The message is a StormByte::CString. std::format runs in the caller's translation unit. This DLL only copies a const char*. A parent passes StormByte::Exception::Path, a std::string_view that lives for the constructor call and is not stored. A bare string is not a path: that would be ambiguous with the format constructor.

A parent prepends its own segment and forwards the format and the arguments. It does not format. A final leaf adds no segment: it inherits the parent constructors. The destructor of each named type is defined in that module's .cxx, so the typeinfo is unique across a DLL.

Constructor & Destructor Documentation

◆ Exception() [1/6]

StormByte::Exception::Exception ( const std::string &  message)
explicit

Constructs from a string.

Text is StormByte: message.

Parameters
messageException text. Not a format string.

◆ Exception() [2/6]

StormByte::Exception::Exception ( std::string &&  message)
explicit

Constructs from a moved string.

Text is StormByte: message.

Parameters
messageException text. Not a format string. Not stolen.

◆ Exception() [3/6]

template<typename... Args>
StormByte::Exception::Exception ( std::format_string< Args... >  fmt,
Args &&...  args 
)
inline

Constructs with std::format.

Text is StormByte: formatted.

Template Parameters
ArgsFormat argument types.
Parameters
fmtFormat string.
argsFormat arguments.
Note
With zero arguments the format string is the message as-is.

◆ Exception() [4/6]

StormByte::Exception::Exception ( const Exception &  e)
default

Copy constructor.

Parameters
eException to copy.

◆ Exception() [5/6]

StormByte::Exception::Exception ( Exception &&  e)
defaultnoexcept

Move constructor.

Parameters
eException to take.

◆ ~Exception()

virtual StormByte::Exception::~Exception ( )
virtualnoexcept

Destructor.

Defined in the Base DLL: this anchors the typeinfo.

◆ Exception() [6/6]

template<typename... Args>
StormByte::Exception::Exception ( Path  path,
std::format_string< Args... >  fmt,
Args &&...  args 
)
inlineprotected

Stores StormByte.path: message, or StormByte: message when path is empty.

Template Parameters
ArgsFormat argument types.
Parameters
pathSegments under StormByte.
fmtFormat string.
argsFormat arguments.
Note
With zero arguments the format string is the message as-is.

Member Function Documentation

◆ operator=() [1/2]

Exception & StormByte::Exception::operator= ( const Exception &  e)
default

Copy assignment.

Parameters
eException to copy.
Returns
*this.

◆ operator=() [2/2]

Exception & StormByte::Exception::operator= ( Exception &&  e)
defaultnoexcept

Move assignment.

Parameters
eException to take.
Returns
*this.

◆ what()

virtual const char * StormByte::Exception::what ( ) const
virtualnoexcept

Message pointer.

Returns
NUL-terminated message owned by this object.

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