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, a trade or a settlement. 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/// ### Clock Errors (`ClockError`)
36/// The current time was asked for in a build without the `clock` feature.
37mod clock;
38
39/// ### Common error kinds (`OperationErrorKind`)
40/// Provides a common set of error kinds used across various modules:
41/// * Validation failures
42/// * Mathematical errors
43/// * Input/output errors
44/// * Data consistency issues
45mod common;
46
47/// ### Decimal Errors (`DecimalError`)
48/// Handles:
49/// * Decimal conversions
50/// * Precision management
51/// * Arithmetic operations
52/// * Boundary validations
53mod decimal;
54
55/// ### Options Errors (`OptionsError`)
56/// Core module handling:
57/// * Option validation errors
58/// * Pricing model failures
59/// * Parameter boundary violations
60/// * Contract specification issues
61mod options;
62
63/// ### Position Errors (`PositionError`)
64/// Manages:
65/// * Position validation
66/// * Strategy operations
67/// * Position limits
68/// * Option style/side compatibility
69pub mod position;
70
71/// ### Settlement Errors (`SettlementError`)
72/// Covers:
73/// * Unsupported option styles
74/// * Missing or late settlement prices
75/// * Events incompatible with the position side
76/// * Obligation arithmetic overflow
77mod settlement;
78
79/// ### Trade Errors (`TradeError`)
80/// Covers:
81/// * Trade execution issues
82/// * Trade parameter validation
83mod trade;
84
85pub use clock::ClockError;
86pub use common::OperationErrorKind;
87pub use decimal::{DecimalError, DecimalResult};
88pub use options::{OptionsError, OptionsResult};
89pub use position::PositionError;
90pub use settlement::SettlementError;
91pub use trade::TradeError;