Replace dummy error handling with expects

This commit is contained in:
Wojciech Kozlowski 2023-04-10 00:12:04 +02:00
parent 5b4185df22
commit 5a6f7e51e7
2 changed files with 8 additions and 19 deletions

View File

@ -1,6 +1,6 @@
//! Module for interacting with the music library.
use std::{fmt, num::ParseIntError, str::Utf8Error};
use std::{num::ParseIntError, str::Utf8Error};
use crate::Artist;
@ -128,12 +128,6 @@ impl From<Utf8Error> for Error {
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{self:#?}")
}
}
/// Trait for interacting with the music library.
pub trait Library {
/// List lirbary items that match the a specific query.

View File

@ -1,4 +1,4 @@
use std::{path::PathBuf, process::exit};
use std::path::PathBuf;
use structopt::StructOpt;
@ -40,18 +40,13 @@ fn main() {
SystemExecutor::default().config(opt.beets_config_file_path.as_deref()),
));
let collection = match beets.list(&Query::new()) {
Ok(collection) => collection,
Err(e) => {
println!("{e}");
exit(1)
}
};
let collection = beets
.list(&Query::new())
.expect("failed to query the library");
let mut database = DatabaseJson::new(Box::new(DatabaseJsonFile::new(&opt.database_file_path)));
if let Err(e) = database.write(&collection) {
println!("{e}");
exit(1)
}
database
.write(&collection)
.expect("failed to write to the database");
}