FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/taskflow/error/error.hpp at master · busySZl/cpp-taskflow · GitHub
busySZl
cpp-taskflow
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
taskflow
/
error
/
error.hpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
106 lines (83 loc) · 2.24 KB
Breadcrumbs
cpp-taskflow
/
taskflow
/
error
/
error.hpp
Copy path
File metadata and controls
106 lines (83 loc) · 2.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#
pragma
once
#
include
<
iostream
>
#
include
<
sstream
>
#
include
<
exception
>
#
include
<
system_error
>
namespace
tf
{
/*
*
@struct Error
@brief The error category of taskflow.
*/
struct
Error
:
public
std
::error_category {
/*
*
@enum Code
@brief Error code definition.
*/
enum
Code :
int
{
SUCCESS
=
0
,
TASKFLOW
,
EXECUTOR
};
/*
*
@brief returns the name of the taskflow error category
*/
inline
const
char
*
name
()
const
noexcept
override
final
;
/*
*
@brief acquires the singleton instance of the taskflow error category
*/
inline
static
const
std::error_category&
get
();
/*
*
@brief query the human-readable string of each error code
*/
inline
std::string
message
(
int
)
const
override
final
;
};
//
Function: name
inline
const
char
*
Error::name
()
const
noexcept
{
return
"
Taskflow error
"
;
}
//
Function: get
inline
const
std::error_category&
Error::get
() {
static
Error instance;
return
instance;
}
//
Function: message
inline
std::string
Error::message
(
int
code)
const
{
switch
(
auto
ec =
static_cast
<Error::Code>(code); ec) {
case
SUCCESS
:
return
"
success
"
;
break
;
case
TASKFLOW
:
return
"
taskflow error
"
;
break
;
case
EXECUTOR
:
return
"
executor error
"
;
break
;
default
:
return
"
unknown
"
;
break
;
};
}
//
Function: make_error_code
//
Argument dependent lookup.
inline
std::error_code
make_error_code
(Error::Code e) {
return
std::error_code
(
static_cast
<
int
>(e),
Error::get
());
}
}
//
end of namespace tf ----------------------------------------------------
//
Register for implicit conversion
namespace
std
{
template
<>
struct
is_error_code_enum
<tf::Error::Code> : true_type {};
}
//
----------------------------------------------------------------------------
namespace
tf
{
//
Procedure: throw_se
//
Throws the system error under a given error code.
template
<
typename
... ArgsT>
void
throw_se
(
const
char
* fname,
const
size_t
line, Error::Code c, ArgsT&&... args) {
std::ostringstream oss;
oss <<
"
[
"
<< fname <<
"
:
"
<< line <<
"
]
"
;
(oss << ... << args);
throw
std::system_error
(c, oss.
str
());
}
}
//
------------------------------------------------------------------------
#
define
TF_THROW
(...) tf::throw_se(__FILE__, __LINE__, __VA_ARGS__);
Back
|
FazBrowse Home
|
New Git URL