pub enum AstroError {
InvalidDate {
year: i32,
month: i32,
day: i32,
message: String,
},
MathError {
operation: String,
kind: MathErrorKind,
message: String,
},
ExternalLibraryError {
function: String,
status_code: i32,
message: String,
},
DataError {
file_type: String,
operation: String,
message: String,
},
CalculationError {
context: String,
message: String,
},
}Expand description
Unified error type for astronomical calculations.
Covers calendar validation, numerical issues, external dependencies,
data access, and algorithmic failures. Use the constructor methods
(invalid_date, math_error, etc.)
for consistent error creation.
Variants§
InvalidDate
Invalid calendar date (e.g., February 30, month 13).
MathError
Numerical computation failure.
ExternalLibraryError
Failure in external library or hardware driver.
DataError
Data access failure (file I/O, network, parsing).
This is the only recoverable error variant — retry or fallback may succeed.
CalculationError
Algorithm or calculation failure.
Implementations§
Source§impl AstroError
impl AstroError
Sourcepub fn invalid_date(year: i32, month: i32, day: i32, reason: &str) -> Self
pub fn invalid_date(year: i32, month: i32, day: i32, reason: &str) -> Self
Creates an InvalidDate error.
Sourcepub fn math_error(operation: &str, kind: MathErrorKind, reason: &str) -> Self
pub fn math_error(operation: &str, kind: MathErrorKind, reason: &str) -> Self
Creates a MathError with the given kind.
Sourcepub fn external_library_error(
function: &str,
status_code: i32,
message: &str,
) -> Self
pub fn external_library_error( function: &str, status_code: i32, message: &str, ) -> Self
Creates an ExternalLibraryError.
Sourcepub fn data_error(file_type: &str, operation: &str, reason: &str) -> Self
pub fn data_error(file_type: &str, operation: &str, reason: &str) -> Self
Creates a DataError (the only recoverable variant).
Sourcepub fn calculation_error(context: &str, reason: &str) -> Self
pub fn calculation_error(context: &str, reason: &str) -> Self
Creates a CalculationError.
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Returns true if retrying or using a fallback might succeed.
Only DataError is recoverable (network retry, alternate source).