Skip to content

Commit d9e6f56

Browse files
Merge pull request #167 from code0-tech/#161-rejcet-flow
throw runtime error when no node function is present for early return
2 parents 0ee93f4 + faae9ed commit d9e6f56

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

crates/taurus/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use taurus_core::context::context::Context;
1919
use taurus_core::context::executor::Executor;
2020
use taurus_core::context::registry::FunctionStore;
2121
use taurus_core::context::signal::Signal;
22+
use taurus_core::runtime::error::RuntimeError;
2223
use tokio::signal;
2324
use tokio::time::sleep;
2425
use tonic_health::pb::health_server::HealthServer;
@@ -41,6 +42,20 @@ fn handle_message(
4142
None => Context::default(),
4243
};
4344

45+
if flow.node_functions.is_empty() {
46+
let duration_millis = start.elapsed().as_millis() as i64;
47+
return (
48+
Signal::Failure(RuntimeError::simple_str(
49+
"InvalidFlow",
50+
"This flow has no nodes to execute!",
51+
)),
52+
RuntimeUsage {
53+
flow_id: flow.flow_id,
54+
duration: duration_millis,
55+
},
56+
);
57+
}
58+
4459
let node_functions: HashMap<i64, NodeFunction> = flow
4560
.node_functions
4661
.into_iter()

0 commit comments

Comments
 (0)