Skip to content

Commit

Permalink
Reduce error size (#32)
Browse files Browse the repository at this point in the history
Resolves: #31
  • Loading branch information
Jake-Shadle committed Sep 26, 2023
1 parent f8e88a1 commit f530166
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
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

0 comments on commit f530166

Please sign in to comment.