StormByte 3.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 (std::string_view message)
 Copies text into StormByte: message.
 Exception (const Exception &other)
 Copy constructor.
 Exception (Exception &&other) noexcept
 Move constructor.
virtual ~Exception () noexcept
 Destructor.
Exception & operator= (const Exception &other)
 Copy assignment.
Exception & operator= (Exception &&other) noexcept
 Move assignment.
virtual const char * what () const noexcept
 Message pointer.

Protected Member Functions

 Exception () noexcept
 Construct without allocating message storage.
 Exception (Path path, std::string_view message)
 Stores StormByte.path: message, or StormByte: message when path is empty.
 Exception (Path path, Safe::String &&message)
 Stores StormByte.path: message, taking the body.
template<typename... Args>
requires (sizeof...(Args) >= 1)
 Exception (Path path, std::string_view pattern, Args &&... args)
 Stores StormByte.path: message after replacing literal {}.

Detailed Description

Base exception type for the suite.

what() is StormByte: message, or StormByte.path: message when a parent passes the segments under StormByte (Safe, Crypto.Crypter). Segments are joined with a dot. The body is a StormByte::Safe::String and does not repeat the path.

A parent passes Path, a std::string_view that lives for the constructor call and is not stored. A bare string is not a path. The token constructor is protected and replaces literal {} with Safe::String::ReplaceToken. It does not call std::format. A derived class uses it. A throw site that is not a derived constructor builds a Safe::String and moves it in.

A parent prepends its own segment and forwards the pattern and the arguments. A final leaf adds no segment. Copy, move and the destructor of each named type are defined in that module's .cxx, so the typeinfo is unique across a DLL.

A leaf that must not allocate uses the empty constructor and overrides what. That leaf does not fill m_what. The message constructor takes a view. A Safe::String converts to that view and is copied.

Constructor & Destructor Documentation

◆ Exception() [1/7]

StormByte::Exception::Exception ( std::string_view message)
explicit

Copies text into StormByte: message.

Parameters
messageException text. Not a format string. A Safe::String converts to this view.

◆ Exception() [2/7]

StormByte::Exception::Exception ( const Exception & other)

Copy constructor.

Defined in the Base DLL.

Parameters
otherException to copy.

◆ Exception() [3/7]

StormByte::Exception::Exception ( Exception && other)
noexcept

Move constructor.

Defined in the Base DLL.

Parameters
otherException to take. other stays valid.

◆ ~Exception()

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

Destructor.

Defined in the Base DLL: this anchors the typeinfo.

Reimplemented in StormByte::Safe::Exception.

◆ Exception() [4/7]

StormByte::Exception::Exception ( )
protectednoexcept

Construct without allocating message storage.

Used by a leaf that overrides what with a static string.

◆ Exception() [5/7]

StormByte::Exception::Exception ( Path path,
std::string_view message )
protected

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

Parameters
pathSegments under StormByte.
messageBody. Not scanned for tokens.

◆ Exception() [6/7]

StormByte::Exception::Exception ( Path path,
Safe::String && message )
protected

Stores StormByte.path: message, taking the body.

Parameters
pathSegments under StormByte.
messageBody. Moved. Not scanned for tokens.

◆ Exception() [7/7]

template<typename... Args>
requires (sizeof...(Args) >= 1)
StormByte::Exception::Exception ( Path path,
std::string_view pattern,
Args &&... args )
inlineprotected

Stores StormByte.path: message after replacing literal {}.

Template Parameters
ArgsViews, numbers, or types that convert to std::string. A number uses std::to_string.
Parameters
pathSegments under StormByte.
patternBody with literal {} tokens. Not a std::format string.
argsReplacements. One per token, in order.

Member Function Documentation

◆ operator=() [1/2]

Exception & StormByte::Exception::operator= ( const Exception & other)

Copy assignment.

Defined in the Base DLL.

Parameters
otherException to copy.
Returns
This exception.

◆ operator=() [2/2]

Exception & StormByte::Exception::operator= ( Exception && other)
noexcept

Move assignment.

Defined in the Base DLL.

Parameters
otherException to take. other stays valid.
Returns
This exception.

◆ what()

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

Message pointer.

A leaf may override this and return static storage.

Returns
NUL-terminated message. Never null.

Reimplemented in StormByte::Safe::AllocationError, and StormByte::Safe::BadOptionalAccess.


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