-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathexc_exception_impl.hpp
More file actions
63 lines (44 loc) · 1.01 KB
/
exc_exception_impl.hpp
File metadata and controls
63 lines (44 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include "exception/api/exc_exception.hpp"
#include <string>
//------------------------------------------------------------------------------
namespace exception {
//------------------------------------------------------------------------------
template < class _BaseException >
class ExceptionImpl : public _BaseException
{
public:
ExceptionImpl( std::string_view _module, std::string_view _code )
: m_module{ _module }
, m_code{ _code }
{
}
std::string getModuleName() const noexcept override
{
return this->m_module;
}
std::string getCode() const noexcept override
{
return this->m_code;
}
const char * what() const noexcept override
{
if( m_msg.empty() )
{
m_msg =
this->getModuleName() +
'-' +
this->getCode() +
": " +
this->getMessage()
;
}
return m_msg.c_str();
}
private:
mutable std::string m_msg;
const std::string m_module;
const std::string m_code;
};
//------------------------------------------------------------------------------
}