Skip to main content

Module errors

Module errors 

Source
Expand description

Error types for astronomical calculations.

This module provides a unified error type AstroError that covers the failure modes encountered in astronomical computations: invalid dates, numerical issues, external library failures, data access problems, and calculation failures.

§Error Categories

VariantUse CaseRecoverable?
InvalidDateCalendar validation failuresNo
MathErrorOverflow, precision loss, division by zeroNo
ExternalLibraryErrorFFI or driver failuresNo
DataErrorFile I/O, network, parsingYes
CalculationErrorAlgorithm failuresNo

§Usage

Most functions return AstroResult<T>, which is Result<T, AstroError>. Use the constructor methods for consistent error creation:

use celestial_core::{AstroError, MathErrorKind};

fn safe_divide(a: f64, b: f64) -> Result<f64, AstroError> {
    if b == 0.0 {
        return Err(AstroError::math_error(
            "safe_divide",
            MathErrorKind::DivisionByZero,
            "divisor is zero",
        ));
    }
    Ok(a / b)
}

Enums§

AstroError
Unified error type for astronomical calculations.
MathErrorKind
Classification of mathematical errors.

Type Aliases§

AstroResult
Convenience alias for Result<T, AstroError>.