Commit 2cd54169 authored by knowledge4igor's avatar knowledge4igor

Get more information about errors

parent ee18c965
...@@ -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)
......
...@@ -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]]
......
...@@ -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) {
......
...@@ -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));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment