-
Notifications
You must be signed in to change notification settings - Fork 174
refactor: create separate error enums for vite_task and vite_workspace #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
branchseer
merged 2 commits into
main
from
10-29-refactor_create_separate_error_enums_for_vite_task_and_vite_workspace
Oct 29, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| use wax; | ||
|
|
||
| #[derive(Debug, thiserror::Error)] | ||
| pub enum Error { | ||
| #[error(transparent)] | ||
| WaxBuild(#[from] wax::BuildError), | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| use std::{ffi::OsString, io, path::Path, sync::Arc}; | ||
|
|
||
| use petgraph::algo::Cycle; | ||
| use vite_path::{ | ||
| AbsolutePath, 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 }, | ||
|
|
||
| #[error("IO error: {err} at {path:?}")] | ||
| IoWithPath { err: io::Error, path: Arc<AbsolutePath> }, | ||
|
|
||
| #[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), | ||
| } | ||
|
|
||
| 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, | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.