Skip to content

Commit 1eda2b2

Browse files
committed
feat: correct error codes
1 parent f50b637 commit 1eda2b2

13 files changed

Lines changed: 94 additions & 63 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Taurus Runtime Error Codes
2+
3+
This document is the canonical catalog for runtime error codes emitted by `taurus-core`.
4+
5+
## Code Format
6+
7+
- `T-STD-XXXXX`: Errors originating inside standard function implementations under `runtime/functions/*`.
8+
- `T-CORE-XXXXXX`: Errors originating from core runtime infrastructure (`engine`, `handler`, type conversion, app-layer mapping).
9+
10+
## Code Table
11+
12+
| Code | Layer | Description | Typical Trigger | Primary Source |
13+
| --- | --- | --- | --- | --- |
14+
| `T-STD-00001` | Standard Functions | A standard runtime function failed due to invalid input shape/type, unsupported value semantics, or function-specific runtime constraints. | Wrong argument type, invalid value conversion, out-of-range operation, malformed function input. | `runtime/functions/*` |
15+
| `T-CORE-000001` | Engine | Requested node id does not exist in the compiled flow plan. | Thunk/reference points to a node id not present in `CompiledFlow`. | `runtime/engine/executor.rs` |
16+
| `T-CORE-000002` | Engine | Handler registry has no implementation for the node's runtime function id. | Function id was not registered in `FunctionStore`. | `runtime/engine/executor.rs` |
17+
| `T-CORE-000003` | Engine | Flow requires remote execution but no remote runtime adapter was configured. | Node execution target is remote while `RemoteRuntime` is `None`. | `runtime/engine/executor.rs` |
18+
| `T-CORE-000004` | Engine | Reference lookup failed in the execution value store. | Missing prior node result, missing flow input path, or unresolved input reference. | `runtime/engine/executor.rs` |
19+
| `T-CORE-000005` | Engine | Remote request cannot be assembled because parameter metadata and resolved values diverge. | Parameter count mismatch during remote request materialization. | `runtime/engine/executor.rs` |
20+
| `T-CORE-000101` | Compiler | Flow compilation failed because a node id appears more than once. | Duplicate `database_id` in input nodes. | `runtime/engine/compiler.rs` |
21+
| `T-CORE-000102` | Compiler | Flow compilation failed because the declared start node is absent. | `start_node_id` not found in node list. | `runtime/engine/compiler.rs` |
22+
| `T-CORE-000103` | Compiler | Flow compilation failed because a `next` edge points to a missing node. | `next_node_id` references unknown node id. | `runtime/engine/compiler.rs` |
23+
| `T-CORE-000104` | Compiler | Flow compilation failed because a parameter is structurally incomplete. | Parameter has no value payload in IR. | `runtime/engine/compiler.rs` |
24+
| `T-CORE-000201` | Handler | Handler argument arity contract was violated before function execution began. | `args!`/`no_args!` macro expected different argument count. | `handler/macros.rs` |
25+
| `T-CORE-000202` | Handler | Handler argument type conversion failed during typed extraction. | `TryFromArgument` expected type does not match provided argument. | `handler/argument.rs` |
26+
| `T-CORE-000301` | App Error Mapping | Application configuration failure mapped into runtime error format. | Invalid/missing runtime config surfaced as `Error::Configuration`. | `types/errors/error.rs` |
27+
| `T-CORE-000302` | App Error Mapping | Invalid application state mapped into runtime error format. | Illegal lifecycle/state transition surfaced as `Error::State`. | `types/errors/error.rs` |
28+
| `T-CORE-000303` | App Error Mapping | Transport/dependency communication failure mapped into runtime error format. | Network/broker/downstream call failure surfaced as `Error::Transport`. | `types/errors/error.rs` |
29+
| `T-CORE-000304` | App Error Mapping | Serialization/deserialization failure mapped into runtime error format. | Encoding/decoding/parsing failure surfaced as `Error::Serialization`. | `types/errors/error.rs` |
30+
| `T-CORE-000399` | App Error Mapping | Internal application failure mapped into runtime error format. | Catch-all non-domain internal failure surfaced as `Error::Internal`. | `types/errors/error.rs` |
31+
| `T-CORE-999999` | Runtime Error Fallback | Default fallback runtime error code when no explicit mapping is provided. | `RuntimeError::default()` used as defensive fallback. | `types/errors/runtime_error.rs` |

crates/taurus-core/src/handler/argument.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub trait TryFromArgument: Sized {
3030

3131
fn type_err(msg: &str, a: &Argument) -> Signal {
3232
Signal::Failure(RuntimeError::new(
33-
"T-RT-000000",
33+
"T-CORE-000202",
3434
"InvalidArgumentRuntimeError",
3535
format!("{} but it was the arugment: {:?}", msg, a),
3636
))
@@ -118,7 +118,7 @@ impl TryFromArgument for ListValue {
118118
kind: Some(Kind::ListValue(list)),
119119
}) => Ok(list.clone()),
120120
_ => Err(Signal::Failure(RuntimeError::new(
121-
"T-RT-000000",
121+
"T-CORE-000202",
122122
"InvalidArgumentRuntimeError",
123123
format!("Expected array (ListValue) but it was: {:?}", a),
124124
))),

crates/taurus-core/src/handler/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//! Handler argument parsing macros.
22
33
/// Pulls typed parameters from a slice of `Argument` using your `TryFromArgument`
4-
/// impls. Fails early with your `Signal::Failure(RuntimeError::new("T-RT-000000", ...))`.
4+
/// impls. Fails early with your `Signal::Failure(RuntimeError::new("T-CORE-000201", ...))`.
55
macro_rules! args {
66
($args_ident:ident => $( $name:ident : $ty:ty ),+ $(,)?) => {
77
// Arity check
88
let __expected: usize = 0usize $(+ { let _ = ::core::any::type_name::<$ty>(); 1usize })*;
99
if $args_ident.len() != __expected {
1010
return $crate::types::signal::Signal::Failure(
11-
$crate::types::errors::runtime_error::RuntimeError::new("T-RT-000000",
11+
$crate::types::errors::runtime_error::RuntimeError::new("T-CORE-000201",
1212
"InvalidArgumentRuntimeError",
1313
format!("Expected {__expected} args but received {}", $args_ident.len()),
1414
)
@@ -43,7 +43,7 @@ macro_rules! no_args {
4343
if !$args_ident.is_empty() {
4444
return $crate::types::signal::Signal::Failure(
4545
$crate::types::errors::runtime_error::RuntimeError::new(
46-
"T-RT-000000",
46+
"T-CORE-000201",
4747
"InvalidArgumentRuntimeError",
4848
format!("Expected 0 args but received {}", $args_ident.len()),
4949
),

crates/taurus-core/src/runtime/engine/compiler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ impl CompileError {
3333
pub fn as_runtime_error(&self) -> RuntimeError {
3434
match self {
3535
CompileError::DuplicateNodeId { node_id } => RuntimeError::new(
36-
"T-RT-000000",
36+
"T-CORE-000101",
3737
"FlowCompileError",
3838
format!("Duplicate node id in flow: {}", node_id),
3939
),
4040
CompileError::StartNodeMissing { node_id } => RuntimeError::new(
41-
"T-RT-000000",
41+
"T-CORE-000102",
4242
"FlowCompileError",
4343
format!("Start node not found in flow: {}", node_id),
4444
),
4545
CompileError::NextNodeMissing {
4646
node_id,
4747
next_node_id,
4848
} => RuntimeError::new(
49-
"T-RT-000000",
49+
"T-CORE-000103",
5050
"FlowCompileError",
5151
format!(
5252
"Node {} points to missing next node {}",
@@ -57,7 +57,7 @@ impl CompileError {
5757
node_id,
5858
parameter_index,
5959
} => RuntimeError::new(
60-
"T-RT-000000",
60+
"T-CORE-000104",
6161
"FlowCompileError",
6262
format!(
6363
"Node {} parameter {} does not contain a value",

crates/taurus-core/src/runtime/engine/executor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'a> EngineExecutor<'a> {
138138
Some(idx) => self.execute_from_index(idx, value_store),
139139
None => ExecutionResult {
140140
signal: Signal::Failure(RuntimeError::new(
141-
"T-ENG-000001",
141+
"T-CORE-000001",
142142
"NodeNotFound",
143143
format!("Node {} not found", node_id),
144144
)),
@@ -178,7 +178,7 @@ impl<'a> EngineExecutor<'a> {
178178
Some(entry) => entry,
179179
None => {
180180
return Signal::Failure(RuntimeError::new(
181-
"T-ENG-000002",
181+
"T-CORE-000002",
182182
"FunctionNotFound",
183183
format!("Function {} not found", node.handler_id),
184184
));
@@ -223,7 +223,7 @@ impl<'a> EngineExecutor<'a> {
223223
Some(remote) => remote,
224224
None => {
225225
return Signal::Failure(RuntimeError::new(
226-
"T-ENG-000003",
226+
"T-CORE-000003",
227227
"RemoteRuntimeNotConfigured",
228228
"Remote runtime not configured",
229229
));
@@ -376,7 +376,7 @@ impl<'a> EngineExecutor<'a> {
376376
},
377377
);
378378
return Err(RuntimeError::new(
379-
"T-ENG-000004",
379+
"T-CORE-000004",
380380
"ReferenceValueNotFound",
381381
"Reference not found in execution value store",
382382
));
@@ -485,7 +485,7 @@ impl<'a> EngineExecutor<'a> {
485485
) -> Result<ExecutionRequest, RuntimeError> {
486486
if node.parameters.len() != values.len() {
487487
return Err(RuntimeError::new(
488-
"T-ENG-000005",
488+
"T-CORE-000005",
489489
"RemoteParameterMismatch",
490490
"Remote parameter count mismatch",
491491
));

crates/taurus-core/src/runtime/functions/array.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn as_list(value: &Value, err: &'static str) -> Result<ListValue, RuntimeError>
5151
match value.kind.clone().unwrap_or(Kind::NullValue(0)) {
5252
Kind::ListValue(lv) => Ok(lv),
5353
_ => Err(RuntimeError::new(
54-
"T-RT-000000",
54+
"T-STD-00001",
5555
"InvalidArgumentRuntimeError",
5656
err,
5757
)),
@@ -62,15 +62,15 @@ fn as_bool(value: &Value) -> Result<bool, RuntimeError> {
6262
match value.kind.clone().unwrap_or(Kind::NullValue(0)) {
6363
Kind::BoolValue(b) => Ok(b),
6464
_ => Err(RuntimeError::new(
65-
"T-RT-000000",
65+
"T-STD-00001",
6666
"InvalidArgumentRuntimeError",
6767
"Expected boolean result from predicate",
6868
)),
6969
}
7070
}
7171

7272
fn fail(category: &str, message: impl Into<String>) -> Signal {
73-
Signal::Failure(RuntimeError::new("T-LST-000000", category, message))
73+
Signal::Failure(RuntimeError::new("T-STD-00001", category, message))
7474
}
7575

7676
fn parse_array_and_thunk<'a>(
@@ -185,7 +185,7 @@ fn at(
185185

186186
if index < 0.0 {
187187
return Signal::Failure(RuntimeError::new(
188-
"T-RT-000000",
188+
"T-STD-00001",
189189
"IndexOutOfBoundsRuntimeError",
190190
"Negative index",
191191
));
@@ -300,7 +300,7 @@ fn find(
300300
}
301301

302302
Signal::Failure(RuntimeError::new(
303-
"T-RT-000000",
303+
"T-STD-00001",
304304
"NotFoundError",
305305
"No item found that satisfies the predicate",
306306
))
@@ -335,7 +335,7 @@ fn find_last(
335335
}
336336

337337
Signal::Failure(RuntimeError::new(
338-
"T-RT-000000",
338+
"T-STD-00001",
339339
"NotFoundError",
340340
"No item found that satisfies the predicate",
341341
))
@@ -372,7 +372,7 @@ fn find_index(
372372
}
373373

374374
Signal::Failure(RuntimeError::new(
375-
"T-RT-000000",
375+
"T-STD-00001",
376376
"NotFoundError",
377377
"No item found that satisfies the predicate",
378378
))
@@ -387,7 +387,7 @@ fn first(
387387
match array.values.first() {
388388
Some(v) => Signal::Success(v.clone()),
389389
None => Signal::Failure(RuntimeError::new(
390-
"T-RT-000000",
390+
"T-STD-00001",
391391
"ArrayEmptyRuntimeError",
392392
"This array is empty",
393393
)),
@@ -403,7 +403,7 @@ fn last(
403403
match array.values.last() {
404404
Some(v) => Signal::Success(v.clone()),
405405
None => Signal::Failure(RuntimeError::new(
406-
"T-RT-000000",
406+
"T-STD-00001",
407407
"ArrayEmptyRuntimeError",
408408
"This array is empty",
409409
)),
@@ -510,7 +510,7 @@ fn push(
510510
args!(args => array_v: Value, item: Value);
511511
let Kind::ListValue(mut array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
512512
return Signal::Failure(RuntimeError::new(
513-
"T-RT-000000",
513+
"T-STD-00001",
514514
"InvalidArgumentRuntimeError",
515515
"Expected first argument to be an array",
516516
));
@@ -529,7 +529,7 @@ fn pop(
529529
args!(args => array_v: Value);
530530
let Kind::ListValue(mut array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
531531
return Signal::Failure(RuntimeError::new(
532-
"T-RT-000000",
532+
"T-STD-00001",
533533
"InvalidArgumentRuntimeError",
534534
"Expected an array as an argument",
535535
));
@@ -548,7 +548,7 @@ fn remove(
548548
args!(args => array_v: Value, item: Value);
549549
let Kind::ListValue(mut array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
550550
return Signal::Failure(RuntimeError::new(
551-
"T-RT-000000",
551+
"T-STD-00001",
552552
"InvalidArgumentRuntimeError",
553553
"Expected first argument to be an array",
554554
));
@@ -575,7 +575,7 @@ fn is_empty(
575575
args!(args => array_v: Value);
576576
let Kind::ListValue(array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
577577
return Signal::Failure(RuntimeError::new(
578-
"T-RT-000000",
578+
"T-STD-00001",
579579
"InvalidArgumentRuntimeError",
580580
"Expected an array as an argument",
581581
));
@@ -593,7 +593,7 @@ fn size(
593593
args!(args => array_v: Value);
594594
let Kind::ListValue(array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
595595
return Signal::Failure(RuntimeError::new(
596-
"T-RT-000000",
596+
"T-STD-00001",
597597
"InvalidArgumentRuntimeError",
598598
"Expected an array as an argument",
599599
));
@@ -609,7 +609,7 @@ fn index_of(
609609
args!(args => array_v: Value, item: Value);
610610
let Kind::ListValue(array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
611611
return Signal::Failure(RuntimeError::new(
612-
"T-RT-000000",
612+
"T-STD-00001",
613613
"InvalidArgumentRuntimeError",
614614
"Expected first argument to be an array",
615615
));
@@ -632,7 +632,7 @@ fn to_unique(
632632
args!(args => array_v: Value);
633633
let Kind::ListValue(array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
634634
return Signal::Failure(RuntimeError::new(
635-
"T-RT-000000",
635+
"T-STD-00001",
636636
"InvalidArgumentRuntimeError",
637637
"Expected an array as an argument",
638638
));
@@ -788,7 +788,7 @@ fn reverse(
788788
args!(args => array_v: Value);
789789
let Kind::ListValue(mut array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
790790
return Signal::Failure(RuntimeError::new(
791-
"T-RT-000000",
791+
"T-STD-00001",
792792
"InvalidArgumentRuntimeError",
793793
"Expected an array as an argument",
794794
));
@@ -807,7 +807,7 @@ fn flat(
807807
args!(args => array_v: Value);
808808
let Kind::ListValue(array) = array_v.kind.ok_or(()).unwrap_or(Kind::NullValue(0)) else {
809809
return Signal::Failure(RuntimeError::new(
810-
"T-RT-000000",
810+
"T-STD-00001",
811811
"InvalidArgumentRuntimeError",
812812
"Expected an array as an argument",
813813
));
@@ -859,7 +859,7 @@ fn min(
859859
Some(m) if all_int => Signal::Success(value_from_i64(min_i64.unwrap_or(*m as i64))),
860860
Some(m) => Signal::Success(value_from_f64(*m)),
861861
None => Signal::Failure(RuntimeError::new(
862-
"T-RT-000000",
862+
"T-STD-00001",
863863
"ArrayEmptyRuntimeError",
864864
"Array is empty",
865865
)),
@@ -899,7 +899,7 @@ fn max(
899899
Some(m) if all_int => Signal::Success(value_from_i64(max_i64.unwrap_or(*m as i64))),
900900
Some(m) => Signal::Success(value_from_f64(*m)),
901901
None => Signal::Failure(RuntimeError::new(
902-
"T-RT-000000",
902+
"T-STD-00001",
903903
"ArrayEmptyRuntimeError",
904904
"Array is empty",
905905
)),

crates/taurus-core/src/runtime/functions/boolean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn from_text(
6666
kind: Some(Kind::BoolValue(b)),
6767
}),
6868
Err(_) => Signal::Failure(RuntimeError::new(
69-
"T-RT-000000",
69+
"T-STD-00001",
7070
"InvalidArgumentRuntimeError",
7171
format!("Failed to parse boolean from string: {:?}", text),
7272
)),

crates/taurus-core/src/runtime/functions/control.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn r#if(
5151
] = args
5252
else {
5353
return Signal::Failure(RuntimeError::new(
54-
"T-RT-000000",
54+
"T-STD-00001",
5555
"InvalidArgumentRuntimeError",
5656
format!("Expected a bool value but received {:?}", args),
5757
));
@@ -82,7 +82,7 @@ fn if_else(
8282
] = args
8383
else {
8484
return Signal::Failure(RuntimeError::new(
85-
"T-RT-000000",
85+
"T-STD-00001",
8686
"InvalidArgumentRuntimeError",
8787
format!("Expected a bool value but received {:?}", args),
8888
));

0 commit comments

Comments
 (0)