Skip to main content

musefs_core/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum CoreError {
5    #[error(transparent)]
6    Db(#[from] musefs_db::DbError),
7    #[error("failed to open database at {path}")]
8    DbOpen {
9        path: std::path::PathBuf,
10        #[source]
11        source: musefs_db::DbError,
12    },
13    #[error(transparent)]
14    Format(#[from] musefs_format::FormatError),
15    #[error(transparent)]
16    InvalidTemplate(#[from] crate::template::TemplateError),
17    #[error("MP4 {box_kind} box is {size} bytes, exceeds the {cap}-byte metadata cap")]
18    Mp4MetadataTooLarge {
19        box_kind: &'static str,
20        size: u64,
21        cap: u64,
22    },
23    #[error("io error: {0}")]
24    Io(#[from] std::io::Error),
25    #[error("backing file changed since scan: {0}")]
26    BackingChanged(String),
27    #[error(
28        "track {track_id} references art {art_id}, which has no metadata row (orphaned track_art — DB contract violation)"
29    )]
30    OrphanedArt { track_id: i64, art_id: i64 },
31    #[error(
32        "track {track_id} art {art_id} has out-of-range picture_type {value} (expected 0..=20)"
33    )]
34    InvalidPictureType {
35        track_id: i64,
36        art_id: i64,
37        value: u32,
38    },
39    #[error("track {track_id} art {art_id} is {byte_len} bytes, exceeds the {cap}-byte art cap")]
40    ArtTooLarge {
41        track_id: i64,
42        art_id: i64,
43        byte_len: u64,
44        cap: u64,
45    },
46    #[error("front/header read of {requested} bytes exceeds the {cap}-byte serve cap")]
47    HeaderTooLarge { requested: u64, cap: u64 },
48    #[error("track {0} not found")]
49    TrackNotFound(i64),
50    #[error("no such inode: {0}")]
51    NoEntry(u64),
52    #[error("inode {0} is a directory")]
53    IsDir(u64),
54    #[error("inode {0} is not a directory")]
55    NotADir(u64),
56    #[error("handle table full")]
57    HandleTableFull,
58}
59
60pub type Result<T> = std::result::Result<T, CoreError>;