16.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit bfbd219d authored by Alessio Netti's avatar Alessio Netti
Browse files

Minor fixes to REST API

- Added a catch for an exception thrown when using on-demand analyzers
- Checking that the HTTPS server is actually running before stopping it in
the destructor
parent 56988601
......@@ -568,10 +568,14 @@ void AnalyticsManager::PUT_analytics_compute(endpointArgs) {
if(a->getStreaming() && a->getDuplicate()) {
continue;
} else {
res.body() = e.what();
res.body() = e.what() + "\n";
res.result(http::status::not_found);
return;
}
} catch(const exception& e) {
res.body() = e.what() + "\n";
res.result(http::status::internal_server_error);
return;
}
if (getQuery("json", queries) == "true") {
boost::property_tree::ptree root, outputs;
......@@ -634,13 +638,13 @@ void AnalyticsManager::PUT_analytics_analyzer(endpointArgs) {
res.body() += reply.response;
res.result(http::status::ok);
} catch(const std::invalid_argument &e) {
res.body() = e.what();
res.body() = e.what() + "\n";
res.result(http::status::bad_request);
} catch(const std::domain_error &e) {
res.body() = e.what();
res.body() = e.what() + "\n";
res.result(http::status::not_found);
} catch(const std::exception &e) {
res.body() = e.what();
res.body() = e.what() + "\n";
res.result(http::status::internal_server_error);
}
}
......
......@@ -13,6 +13,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/asio.hpp>
#include <dlfcn.h>
#include <exception>
#include "logging.h"
#include "RESTHttpsServer.h"
#include "mqttchecker.h"
......
......@@ -214,7 +214,8 @@ protected:
RESTHttpsServer(serverSettings_t settings);
virtual ~RESTHttpsServer() {
stop();
if(_isRunning)
stop();
}
logger_t lg;
......
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