Replace dummy error handling with expects
This commit is contained in:
parent
5b4185df22
commit
5a6f7e51e7
@ -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.
|
||||
|
19
src/main.rs
19
src/main.rs
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user