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

#include <cpp-terminal/private/exception.hpp>

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

Public Member Functions

 ErrnoException (const ErrnoException &)=default
 
 ErrnoException (ErrnoException &&)=default
 
 ErrnoException (const std::int64_t &error, const std::string &context={})
 
 ~ErrnoException () override=default
 
ErrnoExceptionoperator= (ErrnoException &&)=default
 
ErrnoExceptionoperator= (const ErrnoException &)=default
 
- Public Member Functions inherited from Term::Exception
 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
 

Private Member Functions

void build_what () const noexcept final
 

Additional Inherited Members

- Protected Member Functions inherited from Term::Exception
 Exception (const std::int64_t &code) 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 inherited from Term::Exception
static const constexpr std::size_t m_maxSize {256}
 

Detailed Description

Definition at line 73 of file exception.hpp.

Constructor & Destructor Documentation

◆ ErrnoException() [1/3]

Term::Private::ErrnoException::ErrnoException ( const ErrnoException & )
default

◆ ErrnoException() [2/3]

Term::Private::ErrnoException::ErrnoException ( ErrnoException && )
default

◆ ErrnoException() [3/3]

Term::Private::ErrnoException::ErrnoException ( const std::int64_t & error,
const std::string & context = {} )
explicit

Definition at line 154 of file exception.cpp.

154 : Term::Exception(error)
155{
157#if defined(_WIN32)
158 std::wstring message(m_maxSize, L'\0');
159 message = _wcserror_s(&message[0], message.size(), static_cast<int>(error));
161#else
162 std::string message(m_maxSize, '\0');
163 message = ::strerror_r(static_cast<std::int32_t>(error), &message[0], message.size()); // NOLINT(readability-container-data-pointer)
165#endif
166}
void setContext(const std::string &context) noexcept
Definition exception.cpp:65
static const constexpr std::size_t m_maxSize
Definition exception.hpp:41
void setMessage(const std::string &message) noexcept
Definition exception.cpp:63
std::string message() const noexcept
Definition exception.cpp:51
std::string context() const noexcept
Definition exception.cpp:53
std::string to_narrow(const std::wstring &wstr)
Definition unicode.cpp:26

◆ ~ErrnoException()

Term::Private::ErrnoException::~ErrnoException ( )
overridedefault

Member Function Documentation

◆ build_what()

void Term::Private::ErrnoException::build_what ( ) const
finalprivatevirtualnoexcept

Reimplemented from Term::Exception.

Definition at line 168 of file exception.cpp.

169{
170 std::string what{"errno " + std::to_string(code()) + ": " + message()};
171 if(!context().empty()) { what += +" [" + context() + "]"; }
172 setWhat(what);
173}
const char * what() const noexcept override
Definition exception.cpp:43
void setWhat(const std::string &what) const noexcept
Definition exception.cpp:67
std::int64_t code() const noexcept
Definition exception.cpp:49

◆ operator=() [1/2]

ErrnoException & Term::Private::ErrnoException::operator= ( const ErrnoException & )
default

◆ operator=() [2/2]

ErrnoException & Term::Private::ErrnoException::operator= ( ErrnoException && )
default

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