Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add libsolve errors to error message #202

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions crates/rattler_solve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub use libsolv::{
cache_repodata as cache_libsolv_repodata, LibcByteSlice, LibsolvBackend, LibsolvRepoData,
};
pub use solver_backend::SolverBackend;
use std::fmt;

use rattler_conda_types::GenericVirtualPackage;
use rattler_conda_types::{MatchSpec, RepoDataRecord};
Expand All @@ -18,16 +19,31 @@ use rattler_conda_types::{MatchSpec, RepoDataRecord};
#[derive(thiserror::Error, Debug)]
pub enum SolveError {
/// There is no set of dependencies that satisfies the requirements
#[error("unsolvable")]
Unsolvable(Vec<String>),

/// The solver backend returned operations that we dont know how to install.
/// Each string is a somewhat user-friendly representation of which operation was not recognized
/// and can be used for error reporting
#[error("unsupported operations")]
UnsupportedOperations(Vec<String>),
}

impl fmt::Display for SolveError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
SolveError::Unsolvable(operations) => {
write!(
f,
"Cannot solve the request because of: {}",
operations.join(", ")
)
}
SolveError::UnsupportedOperations(operations) => {
write!(f, "Unsupported operations: {}", operations.join(", "))
}
}
}
}

/// Represents a dependency resolution task, to be solved by one of the backends (currently only
/// libsolv is supported)
pub struct SolverTask<TAvailablePackagesIterator> {
Expand Down