Skip to content
Snippets Groups Projects
Commit ac787674 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

removed exception definition form node.h, added errmesage strings

parent 3186ef71
No related branches found
No related tags found
1 merge request!26parser cleanup and fixes
#include "node.h"
#include "cdo_output.h"
#include "cdo_node_attach_exception.h"
Node::Node(std::vector<std::string>::const_iterator p_iter, const std::string &p_oper, const std::string &args,
......@@ -48,21 +49,21 @@ Node::append(std::shared_ptr<Node> &node)
{
Debug(CDO_NODE, "appending %s to %s", node->oper, oper);
if (isFile && !isOutFile && node->isFile) { throw NodeAttachException(node, "File to File not allowed"); }
if (isOutFile && is_done()) { throw NodeAttachException(node, "Could not be assigned, leftover input"); }
if (isFile && !isOutFile && node->isFile) { throw NodeAttachException(node, errmsg_node_file_to_file); }
if (isOutFile && is_done()) { throw NodeAttachException(node, errmsg_node_unassigned); }
if (constraints.streamInCnt >= 0 && (int) children.size() == constraints.streamInCnt)
{
throw NodeAttachException(iter, "To many inputs");
throw NodeAttachException(iter, errmsg_node_to_many_inputs);
}
if (node->numOut() == 0)
{
throw NodeAttachException(node, "operator has no output, cannot be used with pipes unless used first");
throw NodeAttachException(node, errmsg_node_no_output);
}
if (get_restriction() == PositionRestrictions::FilesOnly && !node->isFile)
{
size_t start = ((*iter)[0] == '-') ? 1 : 0;
std::string name = (*iter).substr(start, (*iter).size() - 0);
throw NodeAttachException(node, "This Operator cannot be piped into an operator that takes only files <" + name + ">");
throw NodeAttachException(node, errmsg_node_only_accepts_files);
}
children.push_back(node);
}
......
......@@ -7,6 +7,12 @@
#include <iostream>
#include "modules.h"
static std::string errmsg_node_to_many_inputs = "To many inputs";
static std::string errmsg_node_no_output= "Operator has no output, cannot be used with pipes unless used first";
static std::string errmsg_node_unassigned ="Could not be assigned, leftover input";
static std::string errmsg_node_file_to_file = "Attempted to attach file to file";
static std::string errmsg_node_only_accepts_files = "Operator cannot be piped into an operator that takes only files";
class Node
{
public:
......@@ -54,14 +60,5 @@ public:
std::string to_string();
};
struct NodeAttachException : public std::invalid_argument
{
std::vector<std::string>::const_iterator iter;
NodeAttachException(std::shared_ptr<Node> p_node, const std::string &p_msg)
: std::invalid_argument(p_msg), iter(p_node->iter){};
NodeAttachException(std::vector<std::string>::const_iterator p_iter, const std::string &p_msg)
: std::invalid_argument(p_msg), iter(p_iter){};
};
#endif
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