Skip to content

Commit

Permalink
Align choose version error
Browse files Browse the repository at this point in the history
The error was based on an older version of the dependency provider trait.
  • Loading branch information
konstin committed Jan 29, 2025
1 parent 0af520f commit 8dea8d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
19 changes: 9 additions & 10 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,29 @@ pub type NoSolutionError<DP> = DerivationTree<
#[derive(Error)]
pub enum PubGrubError<DP: DependencyProvider> {
/// There is no solution for this set of dependencies.
#[error("No solution")]
#[error("There is no solution")]
NoSolution(NoSolutionError<DP>),

/// Error arising when the implementer of [DependencyProvider] returned an error in the method
/// [get_dependencies](DependencyProvider::get_dependencies).
/// [`get_dependencies`](DependencyProvider::get_dependencies).
#[error("Retrieving dependencies of {package} {version} failed")]
ErrorRetrievingDependencies {
/// Package whose dependencies we want.
package: DP::P,
/// Version of the package for which we want the dependencies.
version: DP::V,
/// Error raised by the implementer of
/// [DependencyProvider].
/// Error raised by the implementer of [DependencyProvider].
source: DP::Err,
},

/// Error arising when the implementer of [DependencyProvider] returned an error in the method
/// [choose_version](DependencyProvider::choose_version).
#[error("Decision making failed")]
ErrorChoosingPackageVersion(#[source] DP::Err),
/// [`choose_version`](DependencyProvider::choose_version).
#[error("Choosing a version for {package} failed")]
ErrorChoosingVersion { package: DP::P, source: DP::Err },

/// Error arising when the implementer of [DependencyProvider]
/// returned an error in the method [should_cancel](DependencyProvider::should_cancel).
#[error("We should cancel")]
/// returned an error in the method [`should_cancel`](DependencyProvider::should_cancel).
#[error("The solver was cancelled")]
ErrorInShouldCancel(#[source] DP::Err),
}

Expand All @@ -67,7 +66,7 @@ where
.field("version", version)
.field("source", source)
.finish(),
Self::ErrorChoosingPackageVersion(arg0) => f
Self::ErrorChoosingVersion { package: arg0 } => f
.debug_tuple("ErrorChoosingPackageVersion")
.field(arg0)
.finish(),
Expand Down
5 changes: 4 additions & 1 deletion src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ pub fn resolve<DP: DependencyProvider>(

let decision = dependency_provider
.choose_version(&state.package_store[next], term_intersection)
.map_err(PubGrubError::ErrorChoosingPackageVersion)?;
.map_err(|err| PubGrubError::ErrorChoosingVersion {
package: state.package_store[next].clone(),
source: err,
})?;

info!(
"DP chose: {:?} = '{}' @ {:?}",
Expand Down

0 comments on commit 8dea8d1

Please sign in to comment.