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

Reduce error size #32

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
### Changed
- [PR#32](https://github.com/EmbarkStudios/tame-index/pull/32) resolved [#31](https://github.com/EmbarkStudios/tame-index/issues/31) by reducing the size of `Error`.

## [0.6.0] - 2023-09-11
### Changed
- [PR#27](https://github.com/EmbarkStudios/tame-index/pull/27) updated `gix` to 0.53.1. Thanks [@Byron](https://github.com/Byron)!
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum Error {
Json(#[from] serde_json::Error),
/// Failed to deserialize TOML
#[error(transparent)]
Toml(#[from] toml::de::Error),
Toml(#[from] Box<toml::de::Error>),
/// An index entry did not contain any versions
#[error("index entry contained no versions for the crate")]
NoCrateVersions,
Expand Down
11 changes: 3 additions & 8 deletions src/index/git_remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ impl RemoteGitIndex {
} else {
let (repo, out) = gix::prepare_clone_bare(index.url.as_str(), &index.cache.path)
.map_err(Box::new)?
.with_remote_name("origin")?
.with_remote_name("origin")
.map_err(Box::new)?
.configure_remote(|remote| {
Ok(remote.with_refspecs(["+HEAD:refs/remotes/origin/HEAD"], DIR)?)
})
Expand Down Expand Up @@ -405,12 +406,6 @@ pub enum GitError {
#[error(transparent)]
Open(#[from] Box<gix::open::Error>),
#[error(transparent)]
Peel(#[from] gix::reference::peel::Error),
#[error(transparent)]
Head(#[from] gix::reference::head_commit::Error),
#[error(transparent)]
HeadUpdate(#[from] gix::reference::edit::Error),
#[error(transparent)]
Commit(#[from] gix::object::commit::Error),
#[error(transparent)]
InvalidObject(#[from] gix::object::try_into::Error),
Expand All @@ -423,7 +418,7 @@ pub enum GitError {
#[error(transparent)]
Lock(#[from] gix::lock::acquire::Error),
#[error(transparent)]
RemoteName(#[from] gix::remote::name::Error),
RemoteName(#[from] Box<gix::remote::name::Error>),
#[error(transparent)]
Config(#[from] Box<gix::config::Error>),
#[error(transparent)]
Expand Down
4 changes: 2 additions & 2 deletions src/index/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pub(crate) fn read_cargo_config<T>(
Err(err) => return Err(Error::IoPath(err, path)),
};

let toml: toml::Value = toml::from_str(&contents)?;
let toml: toml::Value = toml::from_str(&contents).map_err(Box::new)?;
if let Some(value) = callback(&toml) {
return Ok(Some(value));
}
Expand All @@ -233,7 +233,7 @@ pub(crate) fn read_cargo_config<T>(
let path = home.join("config.toml");
if path.exists() {
let toml: toml::Value =
toml::from_str(&std::fs::read_to_string(&path)?).map_err(Error::Toml)?;
toml::from_str(&std::fs::read_to_string(&path)?).map_err(Box::new)?;
if let Some(value) = callback(&toml) {
return Ok(Some(value));
}
Expand Down