More error catching, copy error in JsonRequest to able to return it to caller and send it per email

This commit is contained in:
einhornimmond 2021-04-12 16:14:26 +02:00
parent 9e049d8477
commit ef1e7e80eb
3 changed files with 19 additions and 4 deletions

View File

@ -52,7 +52,12 @@ void JsonRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Po
Poco::Dynamic::Var parsedResult = parseJsonWithErrorPrintFile(request_stream);
if (parsedResult.size() != 0) {
json_result = handle(parsedResult);
try {
json_result = handle(parsedResult);
}
catch (Poco::Exception& ex) {
json_result = stateError("poco Exception in handle POST Request", ex.displayText());
}
}
else {
json_result = stateError("empty body");
@ -61,7 +66,12 @@ void JsonRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Po
else if(method == "GET") {
Poco::URI uri(request.getURI());
auto queryParameters = uri.getQueryParameters();
json_result = handle(queryParameters);
try {
json_result = handle(queryParameters);
}
catch (Poco::Exception& ex) {
json_result = stateError("poco Exception in handle GET Request", ex.displayText());
}
}
if (json_result) {

View File

@ -121,7 +121,7 @@ JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::JSON:
if (!object.isNull("details")) {
addError(new ParamError(functionName, "details:", object.get("details").convert<std::string>().data()));
}
sendErrorsAsEmail();
sendErrorsAsEmail("", true);
return JSON_REQUEST_RETURN_ERROR;
}
else if (stateString == "success") {

View File

@ -42,7 +42,12 @@ namespace model
{
UNIQUE_LOCK;
std::stringstream ss;
result->stringify(ss);
try {
result->stringify(ss);
}
catch (Poco::Exception& ex) {
addError(new ParamError("PendingTask::setResultJson", "exception by json -> string", ex.displayText()));
}
mResultJsonString = ss.str();
}