|
| 1 | +use std::path::PathBuf; |
| 2 | +use thiserror::Error; |
| 3 | + |
| 4 | +#[derive(Error, Debug)] |
| 5 | +#[error("failed to canonicalize '{path}'")] |
| 6 | +pub struct CanonicalizePathError { |
| 7 | + pub path: PathBuf, |
| 8 | + pub source: std::io::Error, |
| 9 | +} |
| 10 | + |
| 11 | +#[derive(Error, Debug)] |
| 12 | +#[error("failed to copy {from} to {to}")] |
| 13 | +pub struct CopyFileError { |
| 14 | + pub from: PathBuf, |
| 15 | + pub to: PathBuf, |
| 16 | + pub source: std::io::Error, |
| 17 | +} |
| 18 | + |
| 19 | +#[derive(Error, Debug)] |
| 20 | +#[error("failed to create directory {path} and parents")] |
| 21 | +pub struct CreateDirAllError { |
| 22 | + pub path: PathBuf, |
| 23 | + pub source: std::io::Error, |
| 24 | +} |
| 25 | + |
| 26 | +#[derive(Error, Debug)] |
| 27 | +pub enum EnsureDirExistsError { |
| 28 | + #[error(transparent)] |
| 29 | + CreateDirAll(#[from] CreateDirAllError), |
| 30 | + |
| 31 | + #[error("path {0} is not a directory")] |
| 32 | + NotADirectory(PathBuf), |
| 33 | +} |
| 34 | + |
| 35 | +#[derive(Error, Debug)] |
| 36 | +pub enum EnsureParentDirExistsError { |
| 37 | + #[error(transparent)] |
| 38 | + EnsureDirExists(#[from] EnsureDirExistsError), |
| 39 | + |
| 40 | + #[error(transparent)] |
| 41 | + NoParentPath(#[from] NoParentPathError), |
| 42 | +} |
| 43 | + |
| 44 | +#[derive(Error, Debug)] |
| 45 | +#[error("failed to determine parent path for '{0}'")] |
| 46 | +pub struct NoParentPathError(pub PathBuf); |
| 47 | + |
| 48 | +#[derive(Error, Debug)] |
| 49 | +#[error("failed to read directory {path}")] |
| 50 | +pub struct ReadDirError { |
| 51 | + pub path: PathBuf, |
| 52 | + pub source: std::io::Error, |
| 53 | +} |
| 54 | + |
| 55 | +#[derive(Error, Debug)] |
| 56 | +#[error("failed to read from {path}")] |
| 57 | +pub struct ReadFileError { |
| 58 | + pub path: PathBuf, |
| 59 | + pub source: std::io::Error, |
| 60 | +} |
| 61 | + |
| 62 | +#[derive(Error, Debug)] |
| 63 | +#[error("failed to remove directory {path}")] |
| 64 | +pub struct RemoveDirectoryError { |
| 65 | + pub path: PathBuf, |
| 66 | + pub source: std::io::Error, |
| 67 | +} |
| 68 | + |
| 69 | +#[derive(Error, Debug)] |
| 70 | +#[error("failed to write to {path}")] |
| 71 | +pub struct WriteFileError { |
| 72 | + pub path: PathBuf, |
| 73 | + pub source: std::io::Error, |
| 74 | +} |
| 75 | + |
| 76 | +#[derive(Error, Debug)] |
| 77 | +#[error("failed to read metadata of {path}")] |
| 78 | +pub struct ReadMetadataError { |
| 79 | + pub path: PathBuf, |
| 80 | + pub source: std::io::Error, |
| 81 | +} |
| 82 | + |
| 83 | +#[derive(Error, Debug)] |
| 84 | +#[error("failed to read permissions of {path}")] |
| 85 | +pub struct ReadPermissionsError { |
| 86 | + pub path: PathBuf, |
| 87 | + pub source: std::io::Error, |
| 88 | +} |
| 89 | + |
| 90 | +#[derive(Error, Debug)] |
| 91 | +#[error("failed to read {path} as string")] |
| 92 | +pub struct ReadToStringError { |
| 93 | + pub path: PathBuf, |
| 94 | + pub source: std::io::Error, |
| 95 | +} |
| 96 | + |
| 97 | +#[derive(Error, Debug)] |
| 98 | +#[error("failed to remove directory {path} and its contents")] |
| 99 | +pub struct RemoveDirectoryAndContentsError { |
| 100 | + pub path: PathBuf, |
| 101 | + pub source: std::io::Error, |
| 102 | +} |
| 103 | + |
| 104 | +#[derive(Error, Debug)] |
| 105 | +#[error("failed to remove file {path}")] |
| 106 | +pub struct RemoveFileError { |
| 107 | + pub path: PathBuf, |
| 108 | + pub source: std::io::Error, |
| 109 | +} |
| 110 | + |
| 111 | +#[derive(Error, Debug)] |
| 112 | +#[error("Failed to rename {from} to {to}")] |
| 113 | +pub struct RenameError { |
| 114 | + pub from: PathBuf, |
| 115 | + pub to: PathBuf, |
| 116 | + pub source: std::io::Error, |
| 117 | +} |
| 118 | + |
| 119 | +#[derive(Error, Debug)] |
| 120 | +#[error("failed to set permissions of {path}")] |
| 121 | +pub struct SetPermissionsError { |
| 122 | + pub path: PathBuf, |
| 123 | + pub source: std::io::Error, |
| 124 | +} |
| 125 | + |
| 126 | +#[derive(Error, Debug)] |
| 127 | +pub enum SetPermissionsReadWriteError { |
| 128 | + #[error(transparent)] |
| 129 | + ReadPermissions(#[from] ReadPermissionsError), |
| 130 | + |
| 131 | + #[error(transparent)] |
| 132 | + SetPermissions(#[from] SetPermissionsError), |
| 133 | +} |
0 commit comments