#include <cpp-terminal/private/exception.hpp>
Definition at line 43 of file exception.hpp.
◆ WindowsException()
Term::Private::WindowsException::WindowsException |
( |
const std::int64_t & | error, |
|
|
const std::string & | context = std::string() ) |
Definition at line 87 of file exception.cpp.
88{
90 wchar_t* ptr{nullptr};
91 const DWORD cchMsg{FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER,
nullptr,
static_cast<uint32_t
>(
code()), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
reinterpret_cast<wchar_t*
>(&ptr), 0,
nullptr)};
92 if(cchMsg > 0)
93 {
94 auto deleter = [](void* p)
95 {
96 if(p != nullptr) { ::LocalFree(p); }
97 };
98 std::unique_ptr<wchar_t, decltype(deleter)> ptrBuffer(ptr, deleter);
100 if(ret.size() >= 2 && ret[ret.size() - 1] == '\n' && ret[ret.size() - 2] == '\r') ret.erase(ret.size() - 2);
102 }
103 else {
throw Term::Exception(::GetLastError(),
"Error in FormatMessageW"); }
104}
void setContext(const std::string &context) noexcept
void setMessage(const std::string &message) noexcept
std::string context() const noexcept
std::int64_t code() const noexcept
std::string to_narrow(const std::wstring &wstr)
◆ ~WindowsException()
Term::Private::WindowsException::~WindowsException |
( |
| ) |
|
|
overridedefault |
◆ build_what()
void Term::Private::WindowsException::build_what |
( |
| ) |
const |
|
finalprivatevirtualnoexcept |
Reimplemented from Term::Exception.
Definition at line 106 of file exception.cpp.
107{
108 std::string
what{std::string(
"windows error ") + std::to_string(
code()) + std::string(
": ") +
message().c_str()};
111}
const char * what() const noexcept override
void setWhat(const std::string &what) const noexcept
std::string message() const noexcept
The documentation for this class was generated from the following files: