diff options
Diffstat (limited to 'src/server/connection.cc')
-rw-r--r-- | src/server/connection.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/server/connection.cc b/src/server/connection.cc index 499b5a0..efd6802 100644 --- a/src/server/connection.cc +++ b/src/server/connection.cc @@ -5,14 +5,12 @@ #include <ios> #include <arpa/inet.h> #include <cerrno> +#include <nlohmann/json.hpp> #include "connection.h" #include "../p18/commands.h" -#include "../p18/response.h" #include "../logging.h" #include "../common.h" -#include "hexdump/hexdump.h" -#include "signal.h" #define CHECK_ARGUMENTS_LENGTH(__size__) \ if (arguments.size() != (__size__)) { \ @@ -239,8 +237,13 @@ Response Connection::processRequest(char* buf) { resp.type = ResponseType::Error; - auto err = p18::response_type::ErrorResponse(e.what()); - resp.buf << *(err.format(options_.format)); + try { + auto err = p18::response_type::ErrorResponse(e.what()); + resp.buf << *(err.format(options_.format)); + } catch (nlohmann::detail::exception& e) { + myerr << e.what(); + resp.buf << "error while formatting json: " << e.what(); + } } return resp; |