thiserror migration Phase 2: frames + itrfcoord + orbitprop#84
Merged
Conversation
Introduces frames::Error and frames::Result for the frames module,
replacing the anyhow::Error returned by Frame's FromStr impl. The
single bail!("Invalid Frame") site becomes the explicit
Error::InvalidFrame variant.
The frames module is promoted from a private mod to pub mod so
downstream consumers can name and match on the Error type directly
(satkit::frames::Error::InvalidFrame). Frame itself is still
re-exported at the crate root, so existing callers see no change.
Refs #81 (Phase 2)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… enum
Introduces itrfcoord::Error and itrfcoord::Result for the itrfcoord
module, replacing anyhow::Error used by ITRFCoord::from_slice and the
TryFrom<&[f64]> for ITRFCoord impl. Both bail!("Input slice must have
3 elements...") sites collapse onto a single Error::InvalidSliceLength
{ got } variant, which preserves the actual length in the message.
Refs #81 (Phase 2)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… enum
Introduces orbitprop::Error and orbitprop::Result, exposed from
src/orbitprop/error.rs and re-exported via src/orbitprop/mod.rs.
Replaces anyhow::Result throughout satstate.rs, propagator.rs,
settings.rs, and precomputed.rs.
The previously private propagator::PropagationError enum is folded
into the unified module-level Error: its variants (InvalidStateColumns,
NoDenseOutputInSolution, OdeError, RODAS4NoSTM, GaussJackson8NoSTM)
become Error variants directly. New variants cover the bail! sites in
the other files:
- Error::PrecomputedOutOfRange { time, begin, end }
-- Precomputed::interp out-of-range
- Error::Precompute(String)
-- wraps still-anyhow errors from jplephem when building the
precomputed table; will be retyped against jplephem's Error
in Phase 3
- Error::UnsupportedUncertaintyFrame { frame }
-- SatState::set_pos_uncertainty / set_vel_uncertainty rejection
of non-orbital frames
- Error::InvalidGravityOrder { order, degree }
-- PropSettings::set_gravity validation
`numeris::ode::OdeError` does not implement `std::error::Error`, so
its conversion is a manual `From` impl rather than `#[from]`.
Test modules use `use anyhow::Result;` locally so the existing
`?`-conversions from `Instant::from_datetime`, `parse::<f64>()`, etc.
keep working without polluting orbitprop::Error with non-orbitprop
variants.
The Python pysatstate.propagate() binding switches `.map(Self)` to
`Ok(Self(...?))` so it can use anyhow's blanket `From<E: StdError>`
to convert orbitprop::Error into anyhow::Error and then PyErr.
Refs #81 (Phase 2)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the
anyhow→thiserrormigration tracked in #81. Three modules, three commits, branched frommainso it can merge independently of #83 (Phase 1: tle + omm).Refs #81. (Not closing — Phase 3 covers internal modules in a follow-up.)
What changed
frames::Error(src/frames.rs):InvalidFrameSide change:
mod framespromoted topub mod framesso consumers can namesatkit::frames::Error. TheFramere-export at the crate root is unchanged.itrfcoord::Error(src/itrfcoord.rs):InvalidSliceLength { got: usize }— used by bothfrom_sliceandTryFrom<&[f64]>orbitprop::Error(src/orbitprop/error.rs):InvalidStateColumns { c },NoDenseOutputInSolutionOdeError(ode::OdeError)— manualFromimpl (numeris'sOdeErrordoesn't implstd::error::Error)RODAS4NoSTM,GaussJackson8NoSTMPrecomputedOutOfRange { time, begin, end }Precompute(String)— stringified pending Phase 3 (jplephem)UnsupportedUncertaintyFrame { frame: Frame }InvalidGravityOrder { order, degree }The pre-existing
propagator::PropagationErrorenum was folded into the unifiedorbitprop::Error(no externalpub usewas found).Judgment calls worth a look
mod frames→pub mod frames. Small public API expansion, needed so downstream consumers can nameframes::Error. TheFramere-export at the crate root keeps existing imports working.propagator::PropagationErrorfolded intoorbitprop::Error. It was module-local with no external users; unification matches the issue's "module error" pattern.OdeErroruses manualFromimpl rather than#[from]becausenumeris::ode::OdeErroronly implsDisplay, notstd::error::Error. Forward-compatible — will keep working when numeris upgrades.Precompute(String)stringifies jplephem errors. Becomes typed#[from] jplephem::Errorin Phase 3.anyhow::Resultlocally viause anyhow::Result;. Same pattern as Phase 1 — tests touch many?boundaries (Instant::from_datetime,str::parse,io::Error) that aren't worth lifting into the publicErrorenum.pysatstate.propagateswitched.map(Self)toOk(Self(...?))so?convertsorbitprop::Error→anyhow::Errorvia the blanket impl. Only binding that needed touching.Test plan
cargo build— cleancargo build --no-default-features— cleancargo test --release— 159 lib + 41 doc tests passcargo check --manifest-path python/Cargo.toml— clean🤖 Generated with Claude Code