add specialized exception type for bad graphs
This commit is contained in:
@@ -1463,6 +1463,7 @@ void Application::initTypes(void)
|
||||
new ExceptionProducer<Base::IndexError>;
|
||||
new ExceptionProducer<Base::AttributeError>;
|
||||
new ExceptionProducer<Base::RuntimeError>;
|
||||
new ExceptionProducer<Base::BadGraphError>;
|
||||
new ExceptionProducer<Base::NotImplementedError>;
|
||||
new ExceptionProducer<Base::DivisionByZeroError>;
|
||||
new ExceptionProducer<Base::ReferencesError>;
|
||||
|
||||
@@ -2040,7 +2040,7 @@ Document::getDependencyList(const std::vector<App::DocumentObject*>& objs) const
|
||||
std::stringstream ss;
|
||||
ss << "Gathering all dependencies failed, probably due to circular dependencies. Error: ";
|
||||
ss << e.what();
|
||||
throw Base::RuntimeError(ss.str().c_str());
|
||||
throw Base::BadGraphError(ss.str().c_str());
|
||||
}
|
||||
|
||||
std::set<Vertex> out;
|
||||
|
||||
@@ -304,7 +304,7 @@ void _getInListRecursive(std::set<DocumentObject*>& objSet,
|
||||
for (const auto objIt : obj->getInList()) {
|
||||
// if the check object is in the recursive inList we have a cycle!
|
||||
if (objIt == checkObj || depth <= 0) {
|
||||
throw Base::RuntimeError("DocumentObject::getInListRecursive(): cyclic dependency detected!");
|
||||
throw Base::BadGraphError("DocumentObject::getInListRecursive(): cyclic dependency detected!");
|
||||
}
|
||||
|
||||
// if the element was already in the set then there is no need to process it again
|
||||
@@ -335,7 +335,7 @@ void _getOutListRecursive(std::set<DocumentObject*>& objSet,
|
||||
for (const auto objIt : obj->getOutList()) {
|
||||
// if the check object is in the recursive inList we have a cycle!
|
||||
if (objIt == checkObj || depth <= 0) {
|
||||
throw Base::RuntimeError("DocumentObject::getOutListRecursive(): cyclic dependency detected!");
|
||||
throw Base::BadGraphError("DocumentObject::getOutListRecursive(): cyclic dependency detected!");
|
||||
}
|
||||
|
||||
// if the element was already in the set then there is no need to process it again
|
||||
@@ -369,7 +369,7 @@ bool _isInInListRecursive(const DocumentObject* act,
|
||||
return true;
|
||||
// if we reach the depth limit we have a cycle!
|
||||
if (depth <= 0) {
|
||||
throw Base::RuntimeError("DocumentObject::isInInListRecursive(): cyclic dependency detected!");
|
||||
throw Base::BadGraphError("DocumentObject::isInInListRecursive(): cyclic dependency detected!");
|
||||
}
|
||||
|
||||
if (_isInInListRecursive(obj, checkObj, depth - 1))
|
||||
@@ -413,7 +413,7 @@ bool _isInOutListRecursive(const DocumentObject* act,
|
||||
return true;
|
||||
// if we reach the depth limit we have a cycle!
|
||||
if (depth <= 0) {
|
||||
throw Base::RuntimeError("DocumentObject::isInOutListRecursive(): cyclic dependency detected!");
|
||||
throw Base::BadGraphError("DocumentObject::isInOutListRecursive(): cyclic dependency detected!");
|
||||
}
|
||||
|
||||
if (_isInOutListRecursive(obj, checkObj, depth - 1))
|
||||
|
||||
@@ -634,6 +634,28 @@ RuntimeError::RuntimeError(const RuntimeError &inst)
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
BadGraphError::BadGraphError()
|
||||
: RuntimeError("The graph must be a DAG.")
|
||||
{
|
||||
}
|
||||
|
||||
BadGraphError::BadGraphError(const char * sMessage)
|
||||
: RuntimeError(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
BadGraphError::BadGraphError(const std::string& sMessage)
|
||||
: RuntimeError(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
BadGraphError::BadGraphError(const BadGraphError &inst)
|
||||
: RuntimeError(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
NotImplementedError::NotImplementedError()
|
||||
: Exception()
|
||||
{
|
||||
|
||||
@@ -468,6 +468,23 @@ public:
|
||||
virtual ~RuntimeError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The BadGraphError can be used to indicate that a graph is e.g. not a DAG.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport BadGraphError : public RuntimeError
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
BadGraphError();
|
||||
BadGraphError(const char * sMessage);
|
||||
BadGraphError(const std::string& sMessage);
|
||||
/// Construction
|
||||
BadGraphError(const BadGraphError &inst);
|
||||
/// Destruction
|
||||
virtual ~BadGraphError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The NotImplementedError can be used to indicate that an invoked function is not implemented.
|
||||
* @author Werner Mayer
|
||||
|
||||
Reference in New Issue
Block a user