Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
2cd54169
Commit
2cd54169
authored
Mar 08, 2019
by
knowledge4igor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get more information about errors
parent
ee18c965
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
13 deletions
+19
-13
examples/http_server.cc
examples/http_server.cc
+1
-10
include/pistache/common.h
include/pistache/common.h
+11
-0
src/client/client.cc
src/client/client.cc
+2
-2
tests/http_server_test.cc
tests/http_server_test.cc
+5
-1
No files found.
examples/http_server.cc
View file @
2cd54169
...
@@ -10,20 +10,11 @@
...
@@ -10,20 +10,11 @@
#include <pistache/http_headers.h>
#include <pistache/http_headers.h>
#include <pistache/cookie.h>
#include <pistache/cookie.h>
#include <pistache/endpoint.h>
#include <pistache/endpoint.h>
#include <pistache/common.h>
using
namespace
std
;
using
namespace
std
;
using
namespace
Pistache
;
using
namespace
Pistache
;
struct
PrintException
{
void
operator
()(
std
::
exception_ptr
exc
)
const
{
try
{
std
::
rethrow_exception
(
exc
);
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
"An exception occured: "
<<
e
.
what
()
<<
std
::
endl
;
}
}
};
struct
LoadMonitor
{
struct
LoadMonitor
{
LoadMonitor
(
const
std
::
shared_ptr
<
Http
::
Endpoint
>&
endpoint
)
LoadMonitor
(
const
std
::
shared_ptr
<
Http
::
Endpoint
>&
endpoint
)
:
endpoint_
(
endpoint
)
:
endpoint_
(
endpoint
)
...
...
include/pistache/common.h
View file @
2cd54169
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <cassert>
#include <cassert>
#include <cstring>
#include <cstring>
#include <stdexcept>
#include <stdexcept>
#include <iostream>
#include <netdb.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/types.h>
...
@@ -49,6 +50,16 @@
...
@@ -49,6 +50,16 @@
}(); \
}(); \
(void) 0
(void) 0
struct
PrintException
{
void
operator
()(
std
::
exception_ptr
exc
)
const
{
try
{
std
::
rethrow_exception
(
exc
);
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
"An exception occured: "
<<
e
.
what
()
<<
std
::
endl
;
}
}
};
#define unreachable() __builtin_unreachable()
#define unreachable() __builtin_unreachable()
// Until we require C++17 compiler with [[maybe_unused]]
// Until we require C++17 compiler with [[maybe_unused]]
...
...
src/client/client.cc
View file @
2cd54169
...
@@ -152,7 +152,7 @@ Transport::onReady(const Aio::FdSet& fds) {
...
@@ -152,7 +152,7 @@ Transport::onReady(const Aio::FdSet& fds) {
handleIncoming
(
connection
);
handleIncoming
(
connection
);
}
}
else
{
else
{
throw
std
::
runtime_error
(
"Connection error"
);
throw
std
::
runtime_error
(
"Connection error
: problem with reading data from server
"
);
}
}
}
}
else
{
else
{
...
@@ -296,7 +296,7 @@ Transport::handleConnectionQueue() {
...
@@ -296,7 +296,7 @@ Transport::handleConnectionQueue() {
auto
conn
=
data
->
connection
.
lock
();
auto
conn
=
data
->
connection
.
lock
();
if
(
!
conn
)
{
if
(
!
conn
)
{
throw
std
::
runtime_error
(
"Connection error"
);
throw
std
::
runtime_error
(
"Connection error
: problem with establishing connection to server
"
);
}
}
int
res
=
::
connect
(
conn
->
fd
(),
data
->
getAddr
(),
data
->
addr_len
);
int
res
=
::
connect
(
conn
->
fd
(),
data
->
getAddr
(),
data
->
addr_len
);
if
(
res
==
-
1
)
{
if
(
res
==
-
1
)
{
...
...
tests/http_server_test.cc
View file @
2cd54169
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <pistache/http.h>
#include <pistache/http.h>
#include <pistache/client.h>
#include <pistache/client.h>
#include <pistache/endpoint.h>
#include <pistache/endpoint.h>
#include <pistache/common.h>
#include "gtest/gtest.h"
#include "gtest/gtest.h"
...
@@ -100,8 +101,11 @@ int clientLogicFunc(int response_size,
...
@@ -100,8 +101,11 @@ int clientLogicFunc(int response_size,
++
resolver_counter
;
++
resolver_counter
;
}
}
},
},
[
&
reject_counter
](
std
::
exception_ptr
)
[
&
reject_counter
](
std
::
exception_ptr
exc
)
{
{
PrintException
excPrinter
;
std
::
cout
<<
"Reject with reason: "
;
excPrinter
(
exc
);
++
reject_counter
;
++
reject_counter
;
});
});
responses
.
push_back
(
std
::
move
(
response
));
responses
.
push_back
(
std
::
move
(
response
));
...
...
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