1use std::path::PathBuf;
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum Error {
7 #[cfg(feature = "db")]
8 #[error("SurrealDB error: {0}")]
9 DbError(#[from] surrealdb::Error),
10 #[error("Failed to set database path to {0}")]
11 DbPathSetError(PathBuf),
12 #[error("Item is missing an Id.")]
13 NoId,
14 #[error("Item not found.")]
15 NotFound,
16 #[error("Song IO error: {0}")]
17 SongIOError(#[from] SongIOError),
18 #[error("Item not created.")]
19 NotCreated,
20}
21
22#[derive(Error, Debug)]
23pub enum SongIOError {
24 #[error("IO error: {0}")]
25 FsError(#[from] std::io::Error),
26 #[error("Lofty error: {0}")]
27 LoftyError(#[from] lofty::error::LoftyError),
28 #[error("Song missing audio tags")]
29 MissingTags,
30 #[error("File not found: {0}")]
31 FileNotFound(PathBuf),
32 #[error("Song already exists in the database")]
33 SongExists,
34 #[error("couldn't read duration from metadata")]
35 DurationReadError,
36}
37
38pub type StorageResult<T> = std::result::Result<T, Error>;