Skip to content
Snippets Groups Projects
Commit 6cff60da authored by Fabian Reister's avatar Fabian Reister
Browse files

SkillImplementationWrapper: returning result data in case of failure (stead of errormessage)

parent 9e4811f6
No related branches found
No related tags found
1 merge request!484SkillImplementationWrapper: returning result data in case of failure (stead of errormessage)
Pipeline #21143 failed
......@@ -130,9 +130,9 @@ namespace armarx
// set initial parameters that were attached to the execution request (only add as we are not sure whether some updates already arrived)
this->updateSkillParameters(initial_aron_params);
auto makeAbortedResult = [&](const std::string& message)
auto makeAbortedResult = [&](const aron::data::DictPtr& data)
{
updateStatus(SkillStatus::Aborted, createErrorMessageData(message));
updateStatus(SkillStatus::Aborted, data);
std::unique_lock l(skillStatusesMutex);
auto terminated = TerminatedSkillStatusUpdate{
......@@ -145,9 +145,9 @@ namespace armarx
};
auto makeFailedResult = [&](const std::string& message)
auto makeFailedResult = [&](const aron::data::DictPtr& data)
{
updateStatus(SkillStatus::Failed, createErrorMessageData(message));
updateStatus(SkillStatus::Failed, data);
std::unique_lock l(skillStatusesMutex);
auto terminated = TerminatedSkillStatusUpdate{
......@@ -174,15 +174,15 @@ namespace armarx
// }
auto exitAndMakeFailedResult = [&](const std::string& message)
auto exitAndMakeFailedResult = [&](const aron::data::DictPtr& data)
{
skill->exitSkill(); // try to exit skill. Ignore return value
return makeFailedResult(message);
return makeFailedResult(data);
};
auto exitAndMakeAbortedResult = [&](const std::string& message)
auto exitAndMakeAbortedResult = [&](const aron::data::DictPtr& data)
{
skill->exitSkill(); // try to exit skill. Ignore return value
return makeAbortedResult(message);
return makeAbortedResult(data);
};
// Construction succeeded!
......@@ -199,16 +199,16 @@ namespace armarx
{
std::string message = "SkillError 101: The initialization of skill '" +
skillName + "' did not succeed.";
return exitAndMakeFailedResult(message);
return exitAndMakeFailedResult(createErrorMessageData(message));
}
}
catch (const error::SkillAbortedException& ex)
{
return exitAndMakeAbortedResult(GetHandledExceptionString());
return exitAndMakeAbortedResult(createErrorMessageData(GetHandledExceptionString()));
}
catch (const error::SkillFailedException& ex)
{
return exitAndMakeFailedResult(GetHandledExceptionString());
return exitAndMakeFailedResult(createErrorMessageData(GetHandledExceptionString()));
}
catch (const std::exception& ex)
{
......@@ -216,7 +216,7 @@ namespace armarx
"SkillError 101e: An error occured during the initialization of skill '" +
skillName + "'. The error was: " + GetHandledExceptionString();
ARMARX_ERROR_S << message;
return exitAndMakeFailedResult(message);
return exitAndMakeFailedResult(createErrorMessageData(message));
}
// Init succeeded!
......@@ -244,16 +244,16 @@ namespace armarx
std::string message = "SkillError 201: The prepare method of skill '" +
skillName + "' did not succeed.";
ARMARX_ERROR_S << message;
return exitAndMakeFailedResult(message);
return exitAndMakeFailedResult(createErrorMessageData(message));
}
}
catch (const error::SkillAbortedException& ex)
{
return exitAndMakeAbortedResult(GetHandledExceptionString());
return exitAndMakeAbortedResult(createErrorMessageData(GetHandledExceptionString()));
}
catch (const error::SkillFailedException& ex)
{
return exitAndMakeFailedResult(GetHandledExceptionString());
return exitAndMakeFailedResult(createErrorMessageData(GetHandledExceptionString()));
}
catch (const std::exception& ex)
{
......@@ -262,7 +262,7 @@ namespace armarx
skillName +
"'. The error was: " + GetHandledExceptionString();
ARMARX_ERROR_S << message;
return exitAndMakeFailedResult(message);
return exitAndMakeFailedResult(createErrorMessageData(message));
}
// Prepare succeeded!
......@@ -281,22 +281,23 @@ namespace armarx
{
std::string message =
"SkillError 501: The main method of skill '" + skillName + "' did fail.";
return exitAndMakeFailedResult(message);
return exitAndMakeFailedResult(mainRet.data);
}
else if (mainRet.status == TerminatedSkillStatus::Aborted)
{
std::string message =
"SkillError 501: The main method of skill '" + skillName + "' got aborted.";
return exitAndMakeAbortedResult(message);
return exitAndMakeAbortedResult(mainRet.data);
}
}
catch (const error::SkillAbortedException& ex)
{
return exitAndMakeAbortedResult(GetHandledExceptionString());
return exitAndMakeAbortedResult(mainRet.data);
}
catch (const error::SkillFailedException& ex)
{
return exitAndMakeFailedResult(GetHandledExceptionString());
return exitAndMakeFailedResult(mainRet.data);
}
catch (const std::exception& ex)
{
......@@ -304,7 +305,7 @@ namespace armarx
"SkillError 501e: An error occured during the main method of skill '" +
skillName + "'. The error was: " + GetHandledExceptionString();
ARMARX_ERROR_S << message;
return exitAndMakeFailedResult(message);
return exitAndMakeFailedResult(mainRet.data);
}
// Main succeeded!
......@@ -317,18 +318,18 @@ namespace armarx
Skill::ExitResult exitRet = skill->exitSkill();
if (exitRet.status != TerminatedSkillStatus::Succeeded)
{
std::string message = "SkillError 601: The exit method of skill '" + skillName +
"' did not succeed.";
return makeFailedResult(message);
// std::string message = "SkillError 601: The exit method of skill '" + skillName +
// "' did not succeed.";
return makeFailedResult(mainRet.data);
}
}
catch (const error::SkillAbortedException& ex)
{
return makeAbortedResult(GetHandledExceptionString());
return makeAbortedResult(mainRet.data);
}
catch (const error::SkillFailedException& ex)
{
return makeFailedResult(GetHandledExceptionString());
return makeFailedResult(mainRet.data);
}
catch (const std::exception& ex)
{
......@@ -336,7 +337,7 @@ namespace armarx
"SkillError 601e: An error occured during the exit method of skill '" +
skillName + "'. The error was: " + GetHandledExceptionString();
ARMARX_ERROR_S << message;
return makeFailedResult(message);
return makeFailedResult(mainRet.data);
}
// Exit succeeded!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment