Skip to main content

wickra_benchmark_core/
error.rs

1//! The single error type of the benchmark core.
2//!
3//! Every fallible entry point returns [`Result`]. The variants map one-to-one to
4//! the ways running a case can fail before a [`CaseResult`] is even reached: a
5//! malformed case, a strategy that does not deserialize, unusable data, the
6//! backtest engine refusing to run, or a bad command envelope. A case whose
7//! recomputed report simply *disagrees* with its expectation is **not** an error
8//! — that is a successful [`CaseResult`] with `passed == false`.
9//!
10//! [`CaseResult`]: crate::CaseResult
11
12use thiserror::Error;
13
14/// The result of a wickra-benchmark-core operation.
15pub type Result<T> = std::result::Result<T, Error>;
16
17/// Everything that can go wrong while running a case or a suite.
18#[derive(Debug, Error)]
19pub enum Error {
20    /// A case (or suite) is structurally invalid: an empty `id`, an empty
21    /// `dataset_ref`, a malformed `expected_hash`, or a duplicate case `id`.
22    #[error("invalid case: {0}")]
23    BadCase(String),
24
25    /// The embedded `strategy` JSON does not deserialize into a
26    /// wickra-backtest `StrategySpec`.
27    #[error("invalid strategy spec: {0}")]
28    BadSpec(String),
29
30    /// The referenced candle data is missing, empty, or could not be read.
31    #[error("data error: {0}")]
32    Data(String),
33
34    /// The backtest engine refused to run on the given strategy and data.
35    #[error("backtest engine error: {0}")]
36    Backtest(String),
37
38    /// A command envelope (or its embedded JSON) could not be parsed.
39    #[error("parse error: {0}")]
40    Parse(String),
41}