cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
Term::Exception Class Reference

#include <cpp-terminal/exception.hpp>

Inheritance diagram for Term::Exception:
Term::Private::ErrnoException Term::Private::WindowsException

Public Member Functions

 Exception (const std::string &message) noexcept
 
 Exception (const std::int64_t &code, const std::string &message) noexcept
 
 Exception (const Exception &)=default
 
 Exception (Exception &&)=default
 
Exceptionoperator= (Exception &&)=default
 
Exceptionoperator= (const Exception &)=default
 
const char * what () const noexcept override
 
std::int64_t code () const noexcept
 
std::string message () const noexcept
 
std::string context () const noexcept
 
 ~Exception () noexcept override=default
 

Protected Member Functions

 Exception (const std::int64_t &code) noexcept
 
virtual void build_what () const noexcept
 
void setMessage (const std::string &message) noexcept
 
void setContext (const std::string &context) noexcept
 
void setWhat (const std::string &what) const noexcept
 

Static Protected Attributes

static const constexpr std::size_t m_maxSize {256}
 

Private Attributes

std::int64_t m_code {0}
 
std::string m_message
 
std::string m_context
 
std::string m_what
 

Detailed Description

Definition at line 19 of file exception.hpp.

Constructor & Destructor Documentation

◆ Exception() [1/5]

Term::Exception::Exception ( const std::string & message)
explicitnoexcept

Definition at line 39 of file exception.cpp.

std::string message() const noexcept
Definition exception.cpp:51
std::string m_message
Definition exception.hpp:45

◆ Exception() [2/5]

Term::Exception::Exception ( const std::int64_t & code,
const std::string & message )
noexcept

Definition at line 41 of file exception.cpp.

std::int64_t m_code
Definition exception.hpp:44
std::int64_t code() const noexcept
Definition exception.cpp:49

◆ Exception() [3/5]

Term::Exception::Exception ( const Exception & )
default

◆ Exception() [4/5]

Term::Exception::Exception ( Exception && )
default

◆ ~Exception()

Term::Exception::~Exception ( )
overridedefaultnoexcept

◆ Exception() [5/5]

Term::Exception::Exception ( const std::int64_t & code)
explicitprotectednoexcept

Definition at line 55 of file exception.cpp.

55: m_code(code) {}

Member Function Documentation

◆ build_what()

void Term::Exception::build_what ( ) const
protectedvirtualnoexcept

Reimplemented in Term::Private::ErrnoException, and Term::Private::WindowsException.

Definition at line 57 of file exception.cpp.

58{
59 if(0 == m_code) { m_what = m_message; }
60 else { m_what = "error " + std::to_string(m_code) + ": " + m_message; }
61}
std::string m_what
Definition exception.hpp:47

◆ code()

std::int64_t Term::Exception::code ( ) const
noexcept

Definition at line 49 of file exception.cpp.

49{ return m_code; }

◆ context()

std::string Term::Exception::context ( ) const
noexcept

Definition at line 53 of file exception.cpp.

53{ return m_context; }
std::string m_context
Definition exception.hpp:46

◆ message()

std::string Term::Exception::message ( ) const
noexcept

Definition at line 51 of file exception.cpp.

51{ return m_message; }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ setContext()

void Term::Exception::setContext ( const std::string & context)
protectednoexcept

Definition at line 65 of file exception.cpp.

65{ m_context = context; }
std::string context() const noexcept
Definition exception.cpp:53

◆ setMessage()

void Term::Exception::setMessage ( const std::string & message)
protectednoexcept

Definition at line 63 of file exception.cpp.

63{ m_message = message; }

◆ setWhat()

void Term::Exception::setWhat ( const std::string & what) const
protectednoexcept

Definition at line 67 of file exception.cpp.

67{ m_what = what; }
const char * what() const noexcept override
Definition exception.cpp:43

◆ what()

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

Definition at line 43 of file exception.cpp.

44{
45 build_what();
46 return m_what.c_str();
47}
virtual void build_what() const noexcept
Definition exception.cpp:57

Member Data Documentation

◆ m_code

std::int64_t Term::Exception::m_code {0}
private

Definition at line 44 of file exception.hpp.

44{0};

◆ m_context

std::string Term::Exception::m_context
private

Definition at line 46 of file exception.hpp.

◆ m_maxSize

const constexpr std::size_t Term::Exception::m_maxSize {256}
staticconstexprprotected

Definition at line 41 of file exception.hpp.

41{256};

◆ m_message

std::string Term::Exception::m_message
private

Definition at line 45 of file exception.hpp.

◆ m_what

std::string Term::Exception::m_what
mutableprivate

Definition at line 47 of file exception.hpp.


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