Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
fe60c52c
Commit
fe60c52c
authored
Dec 18, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/Error: add MakeErrno(), MakeLastError()
parent
93f45904
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
4 deletions
+28
-4
Error.hxx
src/system/Error.hxx
+28
-4
No files found.
src/system/Error.hxx
View file @
fe60c52c
...
...
@@ -49,6 +49,19 @@ FormatSystemError(std::error_code code, const char *fmt, Args&&... args)
#include <windows.h>
static
inline
std
::
system_error
MakeLastError
(
DWORD
code
,
const
char
*
msg
)
{
return
std
::
system_error
(
std
::
error_code
(
code
,
std
::
system_category
()),
msg
);
}
static
inline
std
::
system_error
MakeLastError
(
const
char
*
msg
)
{
return
MakeLastError
(
GetLastError
(),
msg
);
}
template
<
typename
...
Args
>
static
inline
std
::
system_error
FormatLastError
(
DWORD
code
,
const
char
*
fmt
,
Args
&&
...
args
)
...
...
@@ -64,8 +77,7 @@ FormatLastError(DWORD code, const char *fmt, Args&&... args)
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
nullptr
,
code
,
0
,
p
,
end
-
p
,
nullptr
);
return
std
::
system_error
(
std
::
error_code
(
code
,
std
::
system_category
()),
buffer
);
return
MakeLastError
(
code
,
buffer
);
}
template
<
typename
...
Args
>
...
...
@@ -81,6 +93,19 @@ FormatLastError(const char *fmt, Args&&... args)
#include <errno.h>
#include <string.h>
static
inline
std
::
system_error
MakeErrno
(
int
code
,
const
char
*
msg
)
{
return
std
::
system_error
(
std
::
error_code
(
code
,
std
::
system_category
()),
msg
);
}
static
inline
std
::
system_error
MakeErrno
(
const
char
*
msg
)
{
return
MakeErrno
(
errno
,
msg
);
}
template
<
typename
...
Args
>
static
inline
std
::
system_error
FormatErrno
(
int
code
,
const
char
*
fmt
,
Args
&&
...
args
)
...
...
@@ -94,8 +119,7 @@ FormatErrno(int code, const char *fmt, Args&&... args)
*
p
++
=
' '
;
CopyString
(
p
,
strerror
(
code
),
end
-
p
);
return
std
::
system_error
(
std
::
error_code
(
code
,
std
::
system_category
()),
buffer
);
return
MakeErrno
(
code
,
buffer
);
}
template
<
typename
...
Args
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment