cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
exception.hpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
12#include <cstdint>
13#include <exception>
14#include <string>
15
16namespace Term
17{
18
19class Exception : public std::exception
20{
21public:
22 explicit Exception(const std::string& message) noexcept;
23 Exception(const std::int64_t& code, const std::string& message) noexcept;
24 Exception(const Exception&) = default;
25 Exception(Exception&&) = default;
27 Exception& operator=(const Exception&) = default;
28
29 const char* what() const noexcept override;
30 std::int64_t code() const noexcept;
31 std::string message() const noexcept;
32 std::string context() const noexcept;
33 ~Exception() noexcept override = default;
34
35protected:
36 explicit Exception(const std::int64_t& code) noexcept;
37 virtual void build_what() const noexcept;
38 void setMessage(const std::string& message) noexcept;
39 void setContext(const std::string& context) noexcept;
40 void setWhat(const std::string& what) const noexcept;
41 static const constexpr std::size_t m_maxSize{256};
42
43private:
44 std::int64_t m_code{0};
45 std::string m_message;
46 std::string m_context;
47 mutable std::string m_what;
48};
49
50} // namespace Term
Exception(Exception &&)=default
Exception & operator=(const Exception &)=default
const char * what() const noexcept override
Definition exception.cpp:43
virtual void build_what() const noexcept
Definition exception.cpp:57
Exception & operator=(Exception &&)=default
std::int64_t m_code
Definition exception.hpp:44
void setContext(const std::string &context) noexcept
Definition exception.cpp:65
void setWhat(const std::string &what) const noexcept
Definition exception.cpp:67
static const constexpr std::size_t m_maxSize
Definition exception.hpp:41
Exception(const std::string &message) noexcept
Definition exception.cpp:39
void setMessage(const std::string &message) noexcept
Definition exception.cpp:63
std::string message() const noexcept
Definition exception.cpp:51
std::string m_context
Definition exception.hpp:46
std::string context() const noexcept
Definition exception.cpp:53
std::int64_t code() const noexcept
Definition exception.cpp:49
Exception(const Exception &)=default
std::string m_message
Definition exception.hpp:45
std::string m_what
Definition exception.hpp:47
Definition args.cpp:13