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
553365b9
Commit
553365b9
authored
Sep 09, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log: add std::exception_ptr overloads
parent
100308db
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
3 deletions
+53
-3
Log.cxx
src/Log.cxx
+42
-0
Log.hxx
src/Log.hxx
+11
-3
No files found.
src/Log.cxx
View file @
553365b9
...
...
@@ -136,6 +136,48 @@ FormatError(const std::exception &e, const char *fmt, ...)
}
void
LogError
(
const
std
::
exception_ptr
&
ep
)
{
try
{
std
::
rethrow_exception
(
ep
);
}
catch
(
const
std
::
exception
&
e
)
{
LogError
(
e
);
}
catch
(
const
Error
&
e
)
{
LogError
(
e
);
}
catch
(...)
{
Log
(
exception_domain
,
LogLevel
::
ERROR
,
"Unrecognized exception"
);
}
}
void
LogError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
msg
)
{
try
{
std
::
rethrow_exception
(
ep
);
}
catch
(
const
std
::
exception
&
e
)
{
LogError
(
e
,
msg
);
}
catch
(
const
Error
&
e
)
{
LogError
(
e
,
msg
);
}
catch
(...)
{
FormatError
(
exception_domain
,
"%s: Unrecognized exception"
,
msg
);
}
}
void
FormatError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
fmt
,
...)
{
char
msg
[
1024
];
va_list
ap
;
va_start
(
ap
,
fmt
);
vsnprintf
(
msg
,
sizeof
(
msg
),
fmt
,
ap
);
va_end
(
ap
);
LogError
(
ep
,
msg
);
}
void
LogError
(
const
Error
&
error
)
{
Log
(
error
.
GetDomain
(),
LogLevel
::
ERROR
,
error
.
GetMessage
());
...
...
src/Log.hxx
View file @
553365b9
...
...
@@ -23,9 +23,7 @@
#include "LogLevel.hxx"
#include "Compiler.h"
namespace
std
{
class
exception
;
}
#include <exception>
class
Error
;
class
Domain
;
...
...
@@ -93,6 +91,16 @@ gcc_printf(2,3)
void
FormatError
(
const
std
::
exception
&
e
,
const
char
*
fmt
,
...);
void
LogError
(
const
std
::
exception_ptr
&
ep
);
void
LogError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
msg
);
gcc_printf
(
2
,
3
)
void
FormatError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
fmt
,
...);
gcc_printf
(
2
,
3
)
void
FormatError
(
const
Domain
&
domain
,
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