Skip to content

Commit

Permalink
Add UnknownTriggerNameException; standardise handling of trigger() by…
Browse files Browse the repository at this point in the history
… passing unknown triggers to superclass
  • Loading branch information
ideoforms committed Aug 13, 2024
1 parent 237a592 commit f896b51
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 6 deletions.
10 changes: 10 additions & 0 deletions source/include/signalflow/core/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,14 @@ struct node_not_playing_exception : public std::runtime_error
: std::runtime_error(message) {}
};

struct unknown_trigger_name_exception : public std::runtime_error
{
using std::runtime_error::runtime_error;

unknown_trigger_name_exception()
: std::runtime_error("The specified trigger name is not recognised by this node") {}
unknown_trigger_name_exception(const char *message)
: std::runtime_error(message) {}
};

}
2 changes: 1 addition & 1 deletion source/src/node/buffer/beat-cutter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void BeatCutter::trigger(std::string name, float value)
}
else
{
throw std::runtime_error("Unknown trigger: " + name);
this->Node::trigger(name, value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/src/node/buffer/buffer-looper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void BufferLooper::trigger(std::string name, float value)
}
else
{
throw std::runtime_error("Unknown trigger: " + name);
this->Node::trigger(name, value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/src/node/buffer/buffer-player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void BufferPlayer::trigger(std::string name, float value)
}
else
{
throw std::runtime_error("Unknown trigger: " + name);
this->Node::trigger(name, value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/src/node/fft/fft-buffer-player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void FFTBufferPlayer::trigger(std::string name, float value)
}
else
{
throw std::runtime_error("Unknown trigger: " + name);
this->FFTNode::trigger(name, value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/src/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void Node::set_patch(Patch *patch)

void Node::trigger(std::string name, float value)
{
throw std::runtime_error("Trigger " + name + " is not implemented in node class " + this->name);
throw unknown_trigger_name_exception("Trigger " + name + " is not implemented in node class " + this->name);
}

void Node::poll(float frequency, std::string label)
Expand Down
2 changes: 1 addition & 1 deletion source/src/node/stochastic/stochastic-node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void StochasticNode::trigger(std::string name, float value)
}
else
{
throw std::runtime_error("Unknown trigger: " + name);
this->Node::trigger(name, value);
}
}

Expand Down
1 change: 1 addition & 0 deletions source/src/python/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ void init_python_exceptions(py::module &m)
py::register_exception<signalflow::node_already_playing_exception>(m, "NodeAlreadyPlayingException");
py::register_exception<signalflow::node_not_playing_exception>(m, "NodeNotPlayingException");
py::register_exception<signalflow::cpu_usage_above_limit_exception>(m, "CPUUsageAboveLimitException");
py::register_exception<signalflow::unknown_trigger_name_exception>(m, "UnknownTriggerNameException");
}

0 comments on commit f896b51

Please sign in to comment.