summaryrefslogtreecommitdiff
path: root/src/cmd/show_gen.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-02-03 09:11:49 +0200
committerLars Wirzenius <liw@liw.fi>2021-02-04 09:14:01 +0200
commita2adcb5a90c15b473a2fcf114555443fba8a20ce (patch)
tree7ec36f244daa105b0da774d6705ef736f9135f64 /src/cmd/show_gen.rs
parentbf08ea67ca035fc0e78364450599cefff7cd9bc6 (diff)
downloadobnam2-a2adcb5a90c15b473a2fcf114555443fba8a20ce.tar.gz
refactor: have per-module error enums
This means that a function that parses step bindings can't return an error that the document is missing a title. Such an error return would be nonsensical, and we use the Rust type system to prevent it, at a small cost of being a bit verbose. Additional benefit is that the library portion of Obnam doesn't return anyhow::Result values anymore.
Diffstat (limited to 'src/cmd/show_gen.rs')
-rw-r--r--src/cmd/show_gen.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/cmd/show_gen.rs b/src/cmd/show_gen.rs
index d355389..3dcdbf2 100644
--- a/src/cmd/show_gen.rs
+++ b/src/cmd/show_gen.rs
@@ -5,7 +5,7 @@ use crate::fsentry::FilesystemKind;
use indicatif::HumanBytes;
use tempfile::NamedTempFile;
-pub fn show_generation(config: &ClientConfig, gen_ref: &str) -> anyhow::Result<()> {
+pub fn show_generation(config: &ClientConfig, gen_ref: &str) -> Result<(), ObnamError> {
// Create a named temporary file. We don't meed the open file
// handle, so we discard that.
let dbname = {
@@ -17,11 +17,7 @@ pub fn show_generation(config: &ClientConfig, gen_ref: &str) -> anyhow::Result<(
let client = BackupClient::new(&config.server_url)?;
let genlist = client.list_generations()?;
- let gen_id: String = match genlist.resolve(gen_ref) {
- None => return Err(ObnamError::UnknownGeneration(gen_ref.to_string()).into()),
- Some(id) => id,
- };
-
+ let gen_id: String = genlist.resolve(gen_ref)?;
let gen = client.fetch_generation(&gen_id, &dbname)?;
let files = gen.files()?;