Skip to content
Snippets Groups Projects
Commit d6ed3a82 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Improved error messages

parent 57dd2c6c
No related branches found
No related tags found
No related merge requests found
...@@ -187,8 +187,12 @@ void Aidge::Node::setInputId(const IOIndex_t inId, const IOIndex_t newNodeoutId) ...@@ -187,8 +187,12 @@ void Aidge::Node::setInputId(const IOIndex_t inId, const IOIndex_t newNodeoutId)
void Aidge::Node::addChildOp(std::shared_ptr<Node> otherNode, const IOIndex_t outId, void Aidge::Node::addChildOp(std::shared_ptr<Node> otherNode, const IOIndex_t outId,
const IOIndex_t otherInId) { const IOIndex_t otherInId) {
assert((otherInId < otherNode->nbInputs()) && "Input index out of bound."); AIDGE_ASSERT(otherInId < otherNode->nbInputs(),
assert((outId < nbOutputs()) && "Output index out of bound."); "Input index (#{}) of the node {} (of type {}) is out of bound (it has {} inputs), when trying to add it as a child of node {} (of type {})",
otherInId, otherNode->name(), otherNode->type(), otherNode->nbInputs(), name(), type());
AIDGE_ASSERT(outId < nbOutputs(),
"Output index (#{}) of the node {} (of type {}) is out of bound (it has {} outputs), when trying to add the child node {} (of type {})",
outId, name(), type(), nbOutputs(), otherNode->name(), otherNode->type());
if (otherNode->input(otherInId).second != gk_IODefaultIndex) { if (otherNode->input(otherInId).second != gk_IODefaultIndex) {
fmt::print("Warning, the {}-th Parent of the child node already existed.\n", otherInId); fmt::print("Warning, the {}-th Parent of the child node already existed.\n", otherInId);
} }
...@@ -203,18 +207,11 @@ void Aidge::Node::addChildOp(std::shared_ptr<Node> otherNode, const IOIndex_t ou ...@@ -203,18 +207,11 @@ void Aidge::Node::addChildOp(std::shared_ptr<Node> otherNode, const IOIndex_t ou
void Aidge::Node::addChildView(std::shared_ptr<GraphView> otherGraph, const IOIndex_t outId, void Aidge::Node::addChildView(std::shared_ptr<GraphView> otherGraph, const IOIndex_t outId,
std::pair<std::shared_ptr<Node>, IOIndex_t> otherInId) { std::pair<std::shared_ptr<Node>, IOIndex_t> otherInId) {
assert((otherInId.second < otherInId.first->nbInputs()) && const auto inNodes = otherGraph->inputNodes();
"Other graph input index out of bound."); AIDGE_ASSERT(otherInId.first != nullptr && inNodes.find(otherInId.first) != inNodes.end(),
assert((outId < nbOutputs()) && "Output index out of bound."); "Node {} (of type {}) is not a valid input node of GraphView {}, when trying to add it as a child of node {} (of type {})",
std::set<std::shared_ptr<Node>> inNodes = otherGraph->inputNodes(); (otherInId.first) ? otherInId.first->name() : "#nullptr", (otherInId.first) ? otherInId.first->type() : "", otherGraph->name(), name(), type());
if (inNodes.size() == std::size_t(0)) { // no input Node addChildOp(otherInId.first, outId, otherInId.second);
fmt::print("Cannot add GraphView to the Node. No input node detected.\n");
} else // inNodes.size() >= 1
{
assert((inNodes.find(otherInId.first) !=
inNodes.end())); // assert it really is an input node
addChildOp(otherInId.first, outId, otherInId.second);
}
} }
void Aidge::Node::addChild(std::shared_ptr<Node> otherNode, const IOIndex_t outId, void Aidge::Node::addChild(std::shared_ptr<Node> otherNode, const IOIndex_t outId,
...@@ -229,9 +226,9 @@ void Aidge::Node::addChild(std::shared_ptr<Node> otherNode, const IOIndex_t outI ...@@ -229,9 +226,9 @@ void Aidge::Node::addChild(std::shared_ptr<Node> otherNode, const IOIndex_t outI
void Aidge::Node::addChild(std::shared_ptr<GraphView> otherView, const IOIndex_t outId, void Aidge::Node::addChild(std::shared_ptr<GraphView> otherView, const IOIndex_t outId,
std::pair<std::shared_ptr<Node>, IOIndex_t> otherInId) { std::pair<std::shared_ptr<Node>, IOIndex_t> otherInId) {
if (!otherInId.first) { if (!otherInId.first) {
assert((otherView->inputNodes().size() == 1U) && AIDGE_ASSERT(otherView->inputNodes().size() == 1U,
"Specify an input Node for the GraphView. More or less than one " "Input node of GraphView {} need to be specified, because it has more than one input ({} inputs), when trying to add it as a child of node {} (of type {})",
"Node is not explicit."); otherView->name(), otherView->inputNodes().size(), name(), type());
otherInId.first = *(otherView->inputNodes().begin()); otherInId.first = *(otherView->inputNodes().begin());
} }
otherInId.second = (otherInId.second != gk_IODefaultIndex) otherInId.second = (otherInId.second != gk_IODefaultIndex)
......
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