-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy patherror.rs
More file actions
117 lines (86 loc) · 3.41 KB
/
error.rs
File metadata and controls
117 lines (86 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
use std::{ffi::OsString, io, path::Path};
use fspy::error::SpawnError;
use petgraph::algo::Cycle;
use vite_path::{
RelativePathBuf,
absolute::StripPrefixError,
relative::{FromPathError, InvalidPathDataError},
};
use vite_str::Str;
#[derive(Debug, thiserror::Error)]
pub enum Error {
// Task-specific errors (constructed in vite_task only)
#[error("Duplicate package name `{name}` found at `{path1}` and `{path2}`")]
DuplicatedPackageName { name: Str, path1: RelativePathBuf, path2: RelativePathBuf },
#[error("Package not found in workspace: `{0}`")]
PackageNotFound(Str),
#[error("Duplicate task: `{0}`")]
DuplicatedTask(Str),
#[error("Cycle dependencies detected: {0:?}")]
CycleDependencies(Cycle<petgraph::graph::NodeIndex>),
#[error("Task not found: `{task_request}`")]
TaskNotFound { task_request: Str },
#[error("Task dependency `{name}` not found in package at `{package_path}`")]
TaskDependencyNotFound { name: Str, package_path: RelativePathBuf },
#[error("Ambiguous task request: `{task_request}` (contains multiple '#')")]
AmbiguousTaskRequest { task_request: Str },
#[error("Only one task is allowed in implicit mode (got: `{0}`)")]
OnlyOneTaskRequest(Str),
#[error("Recursive run with scoped task name is not supported: `{0}`")]
RecursiveRunWithScope(Str),
// Errors used by vite_task but not task-specific
#[error("Unrecognized db version: {0}")]
UnrecognizedDbVersion(u32),
#[error("Env value is not valid unicode: {key} = {value:?}")]
EnvValueIsNotValidUnicode { key: Str, value: OsString },
#[error(
"The stripped path ({stripped_path:?}) is not a valid relative path because: {invalid_path_data_error}"
)]
StripPath { stripped_path: Box<Path>, invalid_path_data_error: InvalidPathDataError },
#[error("The path ({path:?}) is not a valid relative path because: {reason}")]
InvalidRelativePath { path: Box<Path>, reason: FromPathError },
#[cfg(unix)]
#[error("Unsupported file type: {0:?}")]
UnsupportedFileType(nix::dir::Type),
#[cfg(windows)]
#[error("Unsupported file type: {0:?}")]
UnsupportedFileType(std::fs::FileType),
// External library errors
#[error(transparent)]
Io(#[from] io::Error),
#[error(transparent)]
JoinPathsError(#[from] std::env::JoinPathsError),
#[error(transparent)]
WaxBuild(#[from] wax::BuildError),
#[error(transparent)]
WaxWalk(#[from] wax::WalkError),
#[error(transparent)]
Utf8Error(#[from] bstr::Utf8Error),
#[error(transparent)]
Serde(#[from] serde_json::Error),
#[error(transparent)]
Sqlite(#[from] rusqlite::Error),
#[error(transparent)]
BincodeEncode(#[from] bincode::error::EncodeError),
#[error(transparent)]
BincodeDecode(#[from] bincode::error::DecodeError),
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
#[error(transparent)]
Glob(#[from] vite_glob::Error),
#[error(transparent)]
Workspace(#[from] vite_workspace::Error),
#[cfg(unix)]
#[error(transparent)]
Nix(#[from] nix::Error),
#[error("Failed to spawn task")]
SpawnError(#[from] SpawnError),
}
impl From<StripPrefixError<'_>> for Error {
fn from(value: StripPrefixError<'_>) -> Self {
Self::StripPath {
stripped_path: Box::from(value.stripped_path),
invalid_path_data_error: value.invalid_path_data_error,
}
}
}