Skip to main content

optionstratlib_core/error/
mod.rs

1//! Errors owned by the core layer.
2//!
3//! Each file here belongs to `optionstratlib-core` because the failure it
4//! describes is raised by a core type: a decimal operation, an option
5//! contract, a position or a trade. Errors raised by higher layers (pricing,
6//! market, analytics, strategies, …) live with those layers, so core never
7//! names an error it cannot raise.
8//!
9//! # Canonical paths (#550)
10//!
11//! Every error type is exported flat from this module, for example
12//! `optionstratlib_core::error::DecimalError`. The file modules `decimal`
13//! and `trade` are private: they held nothing the flat paths do not, and
14//! were public only because 0.21 exposed them. `position` stays public
15//! because its detail enums (`PositionValidationErrorKind`, …) are not
16//! flattened: kind names collide across crates once the facade gathers every
17//! crate's errors (see `position`'s module docs).
18//!
19//! ```rust
20//! use optionstratlib_core::error::{DecimalError, DecimalResult, TradeError};
21//! ```
22//!
23//! ```compile_fail,E0603
24//! use optionstratlib_core::error::decimal::DecimalError;
25//! ```
26//!
27//! ```compile_fail,E0603
28//! use optionstratlib_core::error::decimal::DecimalResult;
29//! ```
30//!
31//! ```compile_fail,E0603
32//! use optionstratlib_core::error::trade::TradeError;
33//! ```
34
35/// ### Common error kinds (`OperationErrorKind`)
36/// Provides a common set of error kinds used across various modules:
37/// * Validation failures
38/// * Mathematical errors
39/// * Input/output errors
40/// * Data consistency issues
41mod common;
42
43/// ### Decimal Errors (`DecimalError`)
44/// Handles:
45/// * Decimal conversions
46/// * Precision management
47/// * Arithmetic operations
48/// * Boundary validations
49mod decimal;
50
51/// ### Options Errors (`OptionsError`)
52/// Core module handling:
53/// * Option validation errors
54/// * Pricing model failures
55/// * Parameter boundary violations
56/// * Contract specification issues
57mod options;
58
59/// ### Position Errors (`PositionError`)
60/// Manages:
61/// * Position validation
62/// * Strategy operations
63/// * Position limits
64/// * Option style/side compatibility
65pub mod position;
66
67/// ### Trade Errors (`TradeError`)
68/// Covers:
69/// * Trade execution issues
70/// * Trade parameter validation
71mod trade;
72
73pub use common::OperationErrorKind;
74pub use decimal::{DecimalError, DecimalResult};
75pub use options::{OptionsError, OptionsResult};
76pub use position::PositionError;
77pub use trade::TradeError;