mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
More error catching, copy error in JsonRequest to able to return it to caller and send it per email
This commit is contained in:
parent
9e049d8477
commit
ef1e7e80eb
@ -52,8 +52,13 @@ void JsonRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Po
|
|||||||
Poco::Dynamic::Var parsedResult = parseJsonWithErrorPrintFile(request_stream);
|
Poco::Dynamic::Var parsedResult = parseJsonWithErrorPrintFile(request_stream);
|
||||||
|
|
||||||
if (parsedResult.size() != 0) {
|
if (parsedResult.size() != 0) {
|
||||||
|
try {
|
||||||
json_result = handle(parsedResult);
|
json_result = handle(parsedResult);
|
||||||
}
|
}
|
||||||
|
catch (Poco::Exception& ex) {
|
||||||
|
json_result = stateError("poco Exception in handle POST Request", ex.displayText());
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
json_result = stateError("empty body");
|
json_result = stateError("empty body");
|
||||||
}
|
}
|
||||||
@ -61,8 +66,13 @@ void JsonRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Po
|
|||||||
else if(method == "GET") {
|
else if(method == "GET") {
|
||||||
Poco::URI uri(request.getURI());
|
Poco::URI uri(request.getURI());
|
||||||
auto queryParameters = uri.getQueryParameters();
|
auto queryParameters = uri.getQueryParameters();
|
||||||
|
try {
|
||||||
json_result = handle(queryParameters);
|
json_result = handle(queryParameters);
|
||||||
}
|
}
|
||||||
|
catch (Poco::Exception& ex) {
|
||||||
|
json_result = stateError("poco Exception in handle GET Request", ex.displayText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (json_result) {
|
if (json_result) {
|
||||||
if (!json_result->isNull("session_id")) {
|
if (!json_result->isNull("session_id")) {
|
||||||
|
|||||||
@ -121,7 +121,7 @@ JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::JSON:
|
|||||||
if (!object.isNull("details")) {
|
if (!object.isNull("details")) {
|
||||||
addError(new ParamError(functionName, "details:", object.get("details").convert<std::string>().data()));
|
addError(new ParamError(functionName, "details:", object.get("details").convert<std::string>().data()));
|
||||||
}
|
}
|
||||||
sendErrorsAsEmail();
|
sendErrorsAsEmail("", true);
|
||||||
return JSON_REQUEST_RETURN_ERROR;
|
return JSON_REQUEST_RETURN_ERROR;
|
||||||
}
|
}
|
||||||
else if (stateString == "success") {
|
else if (stateString == "success") {
|
||||||
|
|||||||
@ -42,7 +42,12 @@ namespace model
|
|||||||
{
|
{
|
||||||
UNIQUE_LOCK;
|
UNIQUE_LOCK;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
try {
|
||||||
result->stringify(ss);
|
result->stringify(ss);
|
||||||
|
}
|
||||||
|
catch (Poco::Exception& ex) {
|
||||||
|
addError(new ParamError("PendingTask::setResultJson", "exception by json -> string", ex.displayText()));
|
||||||
|
}
|
||||||
mResultJsonString = ss.str();
|
mResultJsonString = ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user