CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | Protected Attributes | Friends | List of all members
CppCommon::Exception Class Reference

Exception. More...

#include <exceptions.h>

Inheritance diagram for CppCommon::Exception:
CppCommon::ArgumentException CppCommon::DomainException CppCommon::RuntimeException CppCommon::SecurityException CppCommon::SystemException CppCommon::FileSystemException CppCommon::DLLException

Public Member Functions

 Exception (const std::string &message="")
 Default class constructor. More...
 
 Exception (const Exception &)=default
 
 Exception (Exception &&)=default
 
virtual ~Exception ()=default
 
Exceptionoperator= (const Exception &)=default
 
Exceptionoperator= (Exception &&)=default
 
const std::string & message () const noexcept
 Get exception message. More...
 
const SourceLocationlocation () const noexcept
 Get exception location. More...
 
const char * what () const noexcept override
 Get string identifying exception. More...
 
virtual std::string string () const
 Get string from the current exception. More...
 

Protected Attributes

std::string _cache
 Cached exception string. More...
 
std::string _message
 Exception message. More...
 
SourceLocation _location
 Exception location. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Exception &ex)
 Output exception into the given output stream. More...
 
template<class T >
T && operator+ (const SourceLocation &location, T &&instance)
 Link exception with source location. More...
 

Detailed Description

Exception.

Exception base interface.

Not thread-safe.

Definition at line 33 of file exceptions.h.

Constructor & Destructor Documentation

◆ Exception() [1/3]

CppCommon::Exception::Exception ( const std::string &  message = "")
inlineexplicit

Default class constructor.

Parameters
message- Exception message (default is "")

Definition at line 40 of file exceptions.h.

◆ Exception() [2/3]

CppCommon::Exception::Exception ( const Exception )
default

◆ Exception() [3/3]

CppCommon::Exception::Exception ( Exception &&  )
default

◆ ~Exception()

virtual CppCommon::Exception::~Exception ( )
virtualdefault

Member Function Documentation

◆ location()

const SourceLocation& CppCommon::Exception::location ( ) const
inlinenoexcept

Get exception location.

Definition at line 51 of file exceptions.h.

◆ message()

const std::string& CppCommon::Exception::message ( ) const
inlinenoexcept

Get exception message.

Definition at line 49 of file exceptions.h.

◆ operator=() [1/2]

Exception& CppCommon::Exception::operator= ( const Exception )
default

◆ operator=() [2/2]

Exception& CppCommon::Exception::operator= ( Exception &&  )
default

◆ string()

std::string CppCommon::Exception::string ( ) const
virtual

Get string from the current exception.

Reimplemented in CppCommon::FileSystemException, and CppCommon::SystemException.

Definition at line 29 of file exceptions.cpp.

◆ what()

const char * CppCommon::Exception::what ( ) const
overridenoexcept

Get string identifying exception.

Definition at line 15 of file exceptions.cpp.

Friends And Related Function Documentation

◆ operator+

template<class T >
T&& operator+ ( const SourceLocation location,
T &&  instance 
)
friend

Link exception with source location.

Definition at line 65 of file exceptions.h.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Exception ex 
)
friend

Output exception into the given output stream.

Definition at line 60 of file exceptions.h.

Member Data Documentation

◆ _cache

std::string CppCommon::Exception::_cache
mutableprotected

Cached exception string.

Definition at line 70 of file exceptions.h.

◆ _location

SourceLocation CppCommon::Exception::_location
protected

Exception location.

Definition at line 74 of file exceptions.h.

◆ _message

std::string CppCommon::Exception::_message
protected

Exception message.

Definition at line 72 of file exceptions.h.


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