-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathexc_internal_error.hpp
More file actions
65 lines (46 loc) · 1.69 KB
/
Copy pathexc_internal_error.hpp
File metadata and controls
65 lines (46 loc) · 1.69 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
64
65
#pragma once
#include "exception/ih/exc_exception_impl.hpp"
#include <iostream>
#include <string>
//------------------------------------------------------------------------------
namespace exception
{
//------------------------------------------------------------------------------
class InternalError : public ExceptionImpl< Exception >
{
using BaseClass = ExceptionImpl< Exception >;
public:
InternalError(
std::string_view _file, std::string_view _function, int _line )
: BaseClass( "EXC", "INTERNAL_ERROR" )
, m_file{ _file }
, m_function{ _function }
, m_line{ _line }
{
}
std::string getMessage() const noexcept override
{
return "Internal error " + m_file + ":" + std::to_string( m_line ) +
" " + m_function;
}
private:
const std::string m_file;
const std::string m_function;
const int m_line;
};
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------
#define INTERNAL_ERROR \
::exception::InternalError( __FILE__, __FUNCTION__, __LINE__ )
//------------------------------------------------------------------------------
#define THROW_INTERNAL_ERROR throw INTERNAL_ERROR;
//------------------------------------------------------------------------------
#define INTERNAL_CHECK_ERROR( _condition ) \
if( !( _condition ) ) \
THROW_INTERNAL_ERROR
//------------------------------------------------------------------------------
#define INTERNAL_CHECK_WARRING( _condition ) \
if( !( _condition ) ) \
std::cout << INTERNAL_ERROR.what() << std::endl;
//------------------------------------------------------------------------------