1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Copyright 2026 Mahmoud Harmouch.
//
// Licensed under the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! # Error Types
//!
//! This module defines the unified error type [`LmmError`] used throughout the `lmm` crate,
//! along with the convenience [`Result`] type alias. Every subsystem maps its failure
//! conditions onto a variant of [`LmmError`] so that callers can handle errors with a single
//! `match` branch.
//!
//! # See Also
//! - [`thiserror`](https://docs.rs/thiserror) - derive macro used to automatically generate `std::error::Error` and `Display` implementations.
use Error;
/// The unified error type for the `lmm` crate.
///
/// Each variant corresponds to a distinct failure domain. String payloads carry
/// human-readable context; structured variants expose typed fields where useful.
///
/// # Examples
///
/// ```
/// use lmm::traits::Simulatable;
/// use lmm::error::{LmmError, Result};
///
/// fn divide(a: f64, b: f64) -> Result<f64> {
/// if b == 0.0 {
/// return Err(LmmError::DivisionByZero);
/// }
/// Ok(a / b)
/// }
///
/// assert!(divide(4.0, 2.0).is_ok());
/// assert!(matches!(divide(1.0, 0.0), Err(LmmError::DivisionByZero)));
/// ```
/// Convenience `Result` alias that pins the error type to [`LmmError`].
///
/// # Examples
///
/// ```
/// use lmm::traits::Simulatable;
/// use lmm::error::{LmmError, Result};
///
/// fn parse_positive(s: &str) -> Result<f64> {
/// let v: f64 = s.parse().map_err(|e: std::num::ParseFloatError| {
/// LmmError::ParseError(e.to_string())
/// })?;
/// if v < 0.0 {
/// return Err(LmmError::InvalidExpression);
/// }
/// Ok(v)
/// }
///
/// assert_eq!(parse_positive("3.14").unwrap(), 3.14);
/// assert!(parse_positive("-1").is_err());
/// ```
pub type Result<T> = Result;
// Copyright 2026 Mahmoud Harmouch.
//
// Licensed under the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.