pub enum PositiveError {
InvalidValue {
value: f64,
reason: String,
},
ArithmeticError {
operation: String,
reason: String,
},
ConversionError {
from_type: String,
to_type: String,
reason: String,
},
OutOfBounds {
value: f64,
min: f64,
max: f64,
},
InvalidPrecision {
precision: i32,
reason: String,
},
Other(String),
}Expand description
Represents errors that can occur during positive decimal operations.
This enum provides a structured way to handle various error conditions that may arise when working with positive decimal values, including validation, arithmetic operations, conversions, and precision issues.
§Variants
InvalidValue- Value cannot be represented as a valid positive decimalArithmeticError- Error during mathematical operationsConversionError- Error when converting between typesOutOfBounds- Value exceeds defined limitsInvalidPrecision- Invalid decimal precision settingsOther- Catch-all for other errors
Variants§
InvalidValue
Error when attempting to create a positive decimal from an invalid value.
Occurs when a value cannot be properly represented as a positive decimal, such as when it’s NaN, infinity, negative, or otherwise unsuitable.
Fields
ArithmeticError
Error when performing decimal arithmetic operations.
Occurs during mathematical operations such as addition, subtraction, multiplication, or division when the operation cannot be completed correctly (e.g., division by zero, overflow, result would be negative).
Fields
ConversionError
Error when converting between decimal types.
Occurs when a decimal value cannot be correctly converted from one representation to another, such as between different precision levels or between different decimal formats.
Fields
OutOfBounds
Error when a decimal value exceeds its bounds.
Occurs when a decimal value falls outside of acceptable minimum or maximum values for a specific calculation context.
Fields
InvalidPrecision
Error when decimal precision is invalid.
Occurs when an operation specifies or results in an invalid precision level that cannot be properly handled.
Fields
Other(String)
Catch-all error for other positive decimal errors.
Implementations§
Source§impl PositiveError
impl PositiveError
Sourcepub fn invalid_value(value: f64, reason: &str) -> Self
pub fn invalid_value(value: f64, reason: &str) -> Self
Sourcepub fn arithmetic_error(operation: &str, reason: &str) -> Self
pub fn arithmetic_error(operation: &str, reason: &str) -> Self
Sourcepub fn conversion_error(from_type: &str, to_type: &str, reason: &str) -> Self
pub fn conversion_error(from_type: &str, to_type: &str, reason: &str) -> Self
Sourcepub fn out_of_bounds(value: f64, min: f64, max: f64) -> Self
pub fn out_of_bounds(value: f64, min: f64, max: f64) -> Self
Trait Implementations§
Source§impl Debug for PositiveError
impl Debug for PositiveError
Source§impl Display for PositiveError
impl Display for PositiveError
Source§impl Error for PositiveError
impl Error for PositiveError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()