1use std::io;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
8pub enum Error {
9 #[error("File not found: {0}")]
11 NotFound(String),
12
13 #[error("Permission denied: {0}")]
15 PermissionDenied(String),
16
17 #[error("IO error: {0}")]
19 Io(#[from] io::Error),
20
21 #[error("Invalid path: {0}")]
23 InvalidPath(String),
24
25 #[error("Disk not configured: {0}")]
27 DiskNotConfigured(String),
28
29 #[cfg(feature = "s3")]
31 #[error("S3 error: {0}")]
32 S3(String),
33
34 #[error("Serialization error: {0}")]
36 Serialization(String),
37}
38
39impl Error {
40 pub fn not_found(path: impl Into<String>) -> Self {
42 Self::NotFound(path.into())
43 }
44
45 pub fn permission_denied(msg: impl Into<String>) -> Self {
47 Self::PermissionDenied(msg.into())
48 }
49
50 pub fn invalid_path(path: impl Into<String>) -> Self {
52 Self::InvalidPath(path.into())
53 }
54
55 pub fn disk_not_configured(disk: impl Into<String>) -> Self {
57 Self::DiskNotConfigured(disk.into())
58 }
59}