Expand description
Error types and result alias for Allora.
§Overview
The library uses a single enum [Error] to classify failures across
processors, routing, aggregation, serialization, and miscellaneous cases.
A crate-wide Result<T> type alias simplifies return signatures.
§Goals
- Lightweight – no deep error type hierarchy.
- Human-friendly
Displaymessages viathiserror. - Extensible – new variants can be added in a non-breaking way (add to end).
§When to Use Each Variant
Processor– logic inside a processor failed (validation, transformation).Routing– route selection / content-based routing issues (no match, invalid path).Aggregation– aggregator state or completion failures.Serialization– encoding/decoding payload/header data.Other– fallback / miscellaneous; prefer creating a dedicated variant when patterns emerge.
§Adding New Variants
Add at the end of the enum to avoid changing numeric discriminants (though they are
not relied upon externally). Provide a clear #[error(...)] message and (optionally)
a convenience constructor method.
§Example
use allora_core::{Error, Result};
fn fallible() -> Result<()> { Err(Error::other("boom")) }
assert!(fallible().is_err());use allora_core::{Result, Error};
fn do_work(ok: bool) -> Result<()> {
if ok { Ok(()) } else { Err(Error::processor("failed logic")) }
}
assert!(do_work(true).is_ok());
assert!(matches!(do_work(false), Err(Error::Processor(_))));use allora_core::{Result, Error};
fn demo() -> Result<()> { Ok(()) }use allora_core::{Result, Error};
fn demo() -> Result<()> { Ok(()) }