mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
fixup! PropertyMap: different exception types
This commit is contained in:
parent
30de5e1a8c
commit
94bb50ddc1
@ -150,20 +150,20 @@ private:
|
||||
class Property::error : public std::runtime_error {
|
||||
protected:
|
||||
std::string property_name_;
|
||||
std::string msg_;
|
||||
public:
|
||||
explicit error(const std::string& msg) : std::runtime_error(msg) {}
|
||||
explicit error(const std::string& msg);
|
||||
const std::string& name() const { return property_name_; }
|
||||
void setName(const std::string& name) { property_name_ = name; }
|
||||
void setName(const std::string& name);
|
||||
const char* what() const noexcept override { return msg_.c_str(); }
|
||||
};
|
||||
class Property::undeclared : public Property::error {
|
||||
public:
|
||||
explicit undeclared(const std::string& name);
|
||||
explicit undeclared(const std::string& name, const std::string& msg);
|
||||
explicit undeclared(const std::string& name, const std::string& msg = "undeclared");
|
||||
};
|
||||
class Property::undefined : public Property::error {
|
||||
public:
|
||||
explicit undefined(const std::string& name);
|
||||
explicit undefined(const std::string& name, const std::string& msg);
|
||||
explicit undefined(const std::string& name, const std::string& msg = "undefined");
|
||||
};
|
||||
class Property::type_error : public Property::error {
|
||||
public:
|
||||
|
||||
@ -214,20 +214,24 @@ boost::any fromName(const PropertyMap& other, const std::string& other_name)
|
||||
}
|
||||
|
||||
|
||||
Property::undeclared::undeclared(const std::string& name)
|
||||
: undeclared(name, "Undeclared property: '" + name + "'")
|
||||
Property::error::error(const std::string& msg)
|
||||
: std::runtime_error("Property: " + msg)
|
||||
, msg_(msg)
|
||||
{}
|
||||
|
||||
void Property::error::setName(const std::string& name)
|
||||
{
|
||||
property_name_ = name;
|
||||
// compose message from property name and runtime_errors' msg
|
||||
msg_ = "Property '" + name + "': " + std::runtime_error::what();
|
||||
}
|
||||
|
||||
Property::undeclared::undeclared(const std::string& name, const std::string& msg)
|
||||
: Property::error(msg)
|
||||
{
|
||||
setName(name);
|
||||
}
|
||||
|
||||
Property::undefined::undefined(const std::string& name)
|
||||
: undefined(name, "Undefined property: '" + name + "'")
|
||||
{}
|
||||
|
||||
Property::undefined::undefined(const std::string& name, const std::string& msg)
|
||||
: Property::error(msg)
|
||||
{
|
||||
@ -239,6 +243,5 @@ Property::type_error::type_error(const std::string& current_type, const std::str
|
||||
: Property::error(boost::str(type_error_fmt % current_type % declared_type))
|
||||
{}
|
||||
|
||||
|
||||
} // namespace task_constructor
|
||||
} // namespace moveit
|
||||
|
||||
Loading…
Reference in New Issue
Block a user