Skip to content
Snippets Groups Projects
Commit 335ab739 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Throw proper exception if skill is not found when constructing subskill proxy

parent 56214975
No related branches found
No related tags found
1 merge request!398Minor fixes and improvements in skills
...@@ -245,7 +245,7 @@ namespace armarx ...@@ -245,7 +245,7 @@ namespace armarx
std::string("The skill '" + getSkillId().toString() + "' was asked to stop."); std::string("The skill '" + getSkillId().toString() + "' was asked to stop.");
message += abortedMessage.empty() ? "" : " Additional message: " + abortedMessage; message += abortedMessage.empty() ? "" : " Additional message: " + abortedMessage;
throw error::SkillAbortedException(message); throw error::SkillAbortedException(__PRETTY_FUNCTION__, message);
return; return;
} }
...@@ -256,7 +256,7 @@ namespace armarx ...@@ -256,7 +256,7 @@ namespace armarx
message += abortedMessage.empty() ? "" : " Additional message: " + abortedMessage; message += abortedMessage.empty() ? "" : " Additional message: " + abortedMessage;
ARMARX_WARNING << message; ARMARX_WARNING << message;
throw error::SkillFailedException(message); throw error::SkillFailedException(__PRETTY_FUNCTION__, message);
} }
} }
......
...@@ -12,9 +12,19 @@ namespace armarx ...@@ -12,9 +12,19 @@ namespace armarx
manager(manager) manager(manager)
{ {
ARMARX_CHECK_NOT_NULL(manager); ARMARX_CHECK_NOT_NULL(manager);
skillDescription = SkillDescription::FromIce( IceUtil::Optional<manager::dto::SkillDescription> description =
manager->getSkillDescription(skillId.toManagerIce()).value()); manager->getSkillDescription(skillId.toManagerIce());
ARMARX_CHECK(skillDescription.skillId.isFullySpecified()); if (description)
{
skillDescription = SkillDescription::FromIce(description.value());
ARMARX_CHECK(skillDescription.skillId.isFullySpecified());
}
else
{
std::stringstream reason;
reason << "No skill with ID " << skillId << " found";
throw error::SkillNotFoundException(__PRETTY_FUNCTION__, reason.str());
}
} }
SkillProxy::SkillProxy(const manager::dti::SkillManagerInterfacePrx& manager, SkillProxy::SkillProxy(const manager::dti::SkillManagerInterfacePrx& manager,
......
...@@ -48,32 +48,38 @@ namespace armarx::skills::error ...@@ -48,32 +48,38 @@ namespace armarx::skills::error
} }
}; };
class SkillAbortedException : public armarx::LocalException /**
* @brief Indicates that a skill was not found, e.g., by the skill manager.
*/
class SkillNotFoundException : public SkillException
{ {
public: public:
SkillAbortedException() = delete; SkillNotFoundException() = delete;
SkillAbortedException(const std::string& reason) : LocalException(reason) SkillNotFoundException(const std::string& prettymethod, const std::string& reason) :
SkillException(prettymethod, reason)
{ {
} }
};
class SkillAbortedException : public SkillException
{
public:
SkillAbortedException() = delete;
SkillAbortedException(const std::string& prettymethod, const std::string& reason) : SkillAbortedException(const std::string& prettymethod, const std::string& reason) :
LocalException(prettymethod + ": " + reason + ".") SkillException(prettymethod, reason)
{ {
} }
}; };
class SkillFailedException : public armarx::LocalException class SkillFailedException : public SkillException
{ {
public: public:
SkillFailedException() = delete; SkillFailedException() = delete;
SkillFailedException(const std::string& reason) : LocalException(reason)
{
}
SkillFailedException(const std::string& prettymethod, const std::string& reason) : SkillFailedException(const std::string& prettymethod, const std::string& reason) :
LocalException(prettymethod + ": " + reason + ".") SkillException(prettymethod, reason)
{ {
} }
}; };
......
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