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
1098d271
Commit
1098d271
authored
Dec 18, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/Error: add bridge to std::exception
parent
51168169
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
Log.cxx
src/Log.cxx
+0
-3
Error.cxx
src/util/Error.cxx
+25
-0
Error.hxx
src/util/Error.hxx
+9
-0
No files found.
src/Log.cxx
View file @
1098d271
...
...
@@ -29,9 +29,6 @@
#include <string.h>
#include <errno.h>
/** Domain for std::exception */
static
constexpr
Domain
exception_domain
(
"exception"
);
void
LogFormatV
(
const
Domain
&
domain
,
LogLevel
level
,
const
char
*
fmt
,
va_list
ap
)
{
...
...
src/util/Error.cxx
View file @
1098d271
...
...
@@ -31,6 +31,9 @@
#include "Error.hxx"
#include "Domain.hxx"
#include <exception>
#include <system_error>
#ifdef WIN32
#include <windows.h>
#endif
...
...
@@ -40,6 +43,8 @@
#include <stdio.h>
#include <string.h>
const
Domain
exception_domain
(
"exception"
);
const
Domain
errno_domain
(
"errno"
);
#ifdef WIN32
...
...
@@ -49,6 +54,26 @@ const Domain win32_domain("win32");
Error
::~
Error
()
{}
void
Error
::
Set
(
const
std
::
exception
&
src
)
{
try
{
/* classify the exception */
throw
src
;
}
catch
(
const
std
::
system_error
&
se
)
{
if
(
se
.
code
().
category
()
==
std
::
system_category
())
{
#ifdef WIN32
Set
(
win32_domain
,
se
.
code
().
value
(),
se
.
what
());
#else
Set
(
errno_domain
,
se
.
code
().
value
(),
se
.
what
());
#endif
}
else
Set
(
exception_domain
,
src
.
what
());
}
catch
(...)
{
Set
(
exception_domain
,
src
.
what
());
}
}
void
Error
::
Set
(
const
Domain
&
_domain
,
int
_code
,
const
char
*
_message
)
{
domain
=
&
_domain
;
...
...
src/util/Error.hxx
View file @
1098d271
...
...
@@ -40,6 +40,13 @@
class
Domain
;
namespace
std
{
class
exception
;
}
/** Domain for std::exception */
extern
const
Domain
exception_domain
;
extern
const
Domain
errno_domain
;
#ifdef WIN32
...
...
@@ -126,6 +133,8 @@ public:
message
=
other
.
message
;
}
void
Set
(
const
std
::
exception
&
src
);
void
Set
(
const
Domain
&
_domain
,
int
_code
,
const
char
*
_message
);
void
Set
(
const
Domain
&
_domain
,
const
char
*
_message
)
{
...
...
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