summaryrefslogtreecommitdiffstats
path: root/src/repository/repository.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-06-20 18:42:29 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-08-18 10:07:16 +0200
commit3eff6127ecbe0ce2e87a65d039a4fd624157b979 (patch)
tree33e7a60a6c6a61b543ce2f0da7159575cba309fd /src/repository/repository.rs
parentfb2019b80d4fd4f6a72e4a0d01602fbf3cd6be13 (diff)
Use anyhow!() to create errors instead of format!()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/repository/repository.rs')
-rw-r--r--src/repository/repository.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/repository/repository.rs b/src/repository/repository.rs
index 170c2b0..df9de43 100644
--- a/src/repository/repository.rs
+++ b/src/repository/repository.rs
@@ -70,7 +70,7 @@ impl Repository {
if pkg_file.is_file() {
let buf = std::fs::read_to_string(&pkg_file)
- .with_context(|| format!("Reading {}", pkg_file.display()))?;
+ .with_context(|| anyhow!("Reading {}", pkg_file.display()))?;
// This function has an issue: It loads packages recursively, but if there are
// patches set for a package, these patches are set _relative_ to the current
@@ -126,7 +126,7 @@ impl Repository {
// Merge the new pkg.toml file over the already loaded configuration
config
.merge(config::File::from_str(&buf, config::FileFormat::Toml))
- .with_context(|| format!("Loading contents of {}", pkg_file.display()))?;
+ .with_context(|| anyhow!("Loading contents of {}", pkg_file.display()))?;
let path_relative_to_root = path.strip_prefix(root)?;
@@ -187,13 +187,13 @@ impl Repository {
}
let subdirs = all_subdirs(path)
- .with_context(|| format!("Finding subdirs for {}", pkg_file.display()))?;
+ .with_context(|| anyhow!("Finding subdirs for {}", pkg_file.display()))?;
if subdirs.is_empty() {
progress.tick();
if pkg_file.is_file() {
let package = config.try_into()
- .with_context(|| format!("Failed to parse {} into package", path.display()))
+ .with_context(|| anyhow!("Failed to parse {} into package", path.display()))
.and_then(|package: Package| {
if package.name().is_empty() {
Err(anyhow!("Package name cannot be empty: {}", pkg_file.display()))
@@ -213,7 +213,7 @@ impl Repository {
vec.and_then(|mut v| {
trace!("Recursing into {}", dir.display());
let mut loaded = load_recursive(root, &dir, config.clone(), progress)
- .with_context(|| format!("Reading package from {}", pkg_file.display()))?;
+ .with_context(|| anyhow!("Reading package from {}", pkg_file.display()))?;
v.append(&mut loaded);
Ok(v)
@@ -223,7 +223,7 @@ impl Repository {
}
let inner = load_recursive(path, path, config::Config::default(), progress)
- .with_context(|| format!("Recursing for {}", path.display()))?
+ .with_context(|| anyhow!("Recursing for {}", path.display()))?
.into_iter()
.inspect(|p| trace!("Loading into repository: {:?}", p))
.map_ok(|p| ((p.name().clone(), p.version().clone()), p))