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
08bf4f74
Commit
08bf4f74
authored
Dec 05, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/FatalError: add FatalSystemError() overload with WIN32 error code
parent
a838a034
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
10 deletions
+30
-10
FatalError.cxx
src/system/FatalError.cxx
+18
-10
FatalError.hxx
src/system/FatalError.hxx
+12
-0
No files found.
src/system/FatalError.cxx
View file @
08bf4f74
...
...
@@ -74,23 +74,31 @@ FatalError(const char *msg, const Error &error)
FormatFatalError
(
"%s: %s"
,
msg
,
error
.
GetMessage
());
}
#ifdef WIN32
void
FatalSystemError
(
const
char
*
msg
,
DWORD
code
)
{
char
buffer
[
256
];
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
nullptr
,
code
,
0
,
buffer
,
sizeof
(
buffer
),
nullptr
);
FormatFatalError
(
"%s: %s"
,
msg
,
buffer
);
}
#endif
void
FatalSystemError
(
const
char
*
msg
)
{
const
char
*
system_error
;
#ifdef WIN32
char
buffer
[
256
];
FormatMessageA
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
nullptr
,
GetLastError
(),
0
,
buffer
,
sizeof
(
buffer
),
nullptr
);
system_error
=
buffer
;
FatalSystemError
(
msg
,
GetLastError
());
#else
system_error
=
strerror
(
errno
);
#endif
const
char
*
system_error
=
strerror
(
errno
);
FormatError
(
fatal_error_domain
,
"%s: %s"
,
msg
,
system_error
);
Abort
();
#endif
}
void
...
...
src/system/FatalError.hxx
View file @
08bf4f74
...
...
@@ -23,6 +23,10 @@
#include "check.h"
#include "Compiler.h"
#ifdef WIN32
#include <windef.h>
#endif
class
Error
;
/**
...
...
@@ -53,6 +57,14 @@ gcc_noreturn
void
FatalSystemError
(
const
char
*
msg
);
#ifdef WIN32
gcc_noreturn
void
FatalSystemError
(
const
char
*
msg
,
DWORD
code
);
#endif
gcc_noreturn
void
FormatFatalSystemError
(
const
char
*
fmt
,
...);
...
...
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