anni_workspace/
error.rs

1use crate::WorkspaceAlbumState;
2use anni_repo::error::AlbumApplyError;
3use std::path::PathBuf;
4use uuid::Uuid;
5
6#[derive(thiserror::Error, Debug)]
7pub enum WorkspaceError {
8    #[error("Workspace does not exist in given path.")]
9    NotAWorkspace,
10
11    #[error("Workspace was not found.")]
12    WorkspaceNotFound,
13
14    #[error("Album with id: {0} exists in workspace")]
15    DuplicatedAlbumId(Uuid),
16
17    #[error("Directory is not an album directory: {0}")]
18    NotAnAlbum(PathBuf),
19
20    #[error("Invalid album state: {0:?}")]
21    InvalidAlbumState(WorkspaceAlbumState),
22
23    #[error("Album {album_id} already exists at {path}")]
24    AlbumExists { album_id: Uuid, path: PathBuf },
25
26    #[error("Album at {0} was locked")]
27    AlbumLocked(PathBuf),
28
29    #[error("Album cover not found at {0}")]
30    CoverNotFound(PathBuf),
31
32    #[error("Invalid album symlink at: {0}")]
33    InvalidAlbumLink(PathBuf),
34
35    #[error("Album not found: {0}")]
36    AlbumNotFound(Uuid),
37
38    #[error("Invalid album found at {0}. If there's only one disc, then subdirectories are not allowed. If there're multiple discs, then having flac files in root directory is unacceptable.")]
39    InvalidAlbumDiscStructure(PathBuf),
40
41    #[error("User aborted")]
42    UserAborted,
43
44    #[error(transparent)]
45    DeserializeError(#[from] toml::de::Error),
46
47    #[error(transparent)]
48    InvalidUuid(#[from] uuid::Error),
49
50    #[error(transparent)]
51    IOError(#[from] std::io::Error),
52
53    #[error(transparent)]
54    RepoError(#[from] anni_repo::error::Error),
55
56    #[error("Invalid flac file {path}: {error}")]
57    FlacError {
58        path: PathBuf,
59        error: anni_flac::error::FlacError,
60    },
61
62    // TODO: print full string
63    #[error("Failed to extract album info from dir name")]
64    FailedToExtractAlbumInfo,
65
66    #[error("Unexpected file {0} found.")]
67    UnexpectedFile(PathBuf),
68
69    #[error("Publish target directory {0} was not found.")]
70    PublishTargetNotFound(PathBuf),
71
72    #[error(transparent)]
73    ApplyError(#[from] AlbumApplyError),
74}