mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
database: Add error for missing items
This commit is contained in:
parent
d9746c8ab4
commit
ac14beb665
4 changed files with 21 additions and 46 deletions
|
|
@ -256,22 +256,18 @@ impl Database {
|
|||
|
||||
let recording = self
|
||||
.get_recording(&recording_id)?
|
||||
.ok_or(Error::Other(format!(
|
||||
"Failed to get recording ({}) for track ({}).",
|
||||
recording_id,
|
||||
row.id,
|
||||
)))?;
|
||||
.ok_or(Error::MissingItem("recording", recording_id))?;
|
||||
|
||||
let mut part_indices = Vec::new();
|
||||
|
||||
let work_parts = row
|
||||
.work_parts
|
||||
.split(',');
|
||||
let work_parts = row.work_parts.split(',');
|
||||
|
||||
for part_index in work_parts {
|
||||
if !part_index.is_empty() {
|
||||
let index = str::parse(part_index)
|
||||
.or(Err(Error::Other(format!("Failed to parse part index from '{}'.", row.work_parts))))?;
|
||||
let index = str::parse(part_index).or(Err(Error::Other(format!(
|
||||
"Failed to parse part index from '{}'.",
|
||||
row.work_parts
|
||||
))))?;
|
||||
|
||||
part_indices.push(index);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue