Skip to content
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

Add separate ExampleNotFound Error instead of mis-using BinNotFound #28

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub enum Error {
Io(PathBuf, IoError),
Toml(PathBuf, TomlError),
BinNotFound(String),
ExampleNotFound(String),
DuplicateBin(String),
DuplicateExample(String),
}
Expand Down Expand Up @@ -78,6 +79,7 @@ Alternatively, to keep it out of the workspace, add an empty `[workspace]` table
Self::Io(path, error) => return write!(f, "{}: {}", path.display(), error),
Self::Toml(file, error) => return write!(f, "{}: {}", file.display(), error),
Self::BinNotFound(name) => return write!(f, "Can't find `{name}` bin at `src/bin/{name}.rs` or `src/bin/{name}/main.rs`. Please specify bin.path if you want to use a non-default path.", name = name),
Self::ExampleNotFound(name) => return write!(f, "Can't find `{name}` example at `examples/{name}.rs` or `examples/{name}/main.rs`. Please specify examples.path if you want to use a non-default path.", name = name),
Self::DuplicateBin(name) => return write!(f, "found duplicate binary name {name}, but all binary targets must have a unique name"),
Self::DuplicateExample(name) => return write!(f, "found duplicate example name {name}, but all example targets must have a unique name"),
})
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Subcommand {
.path
.clone()
.or_else(|| find_main_file(&root_dir.join("examples"), &example.name))
.ok_or_else(|| Error::BinNotFound(example.name.clone()))?;
.ok_or_else(|| Error::ExampleNotFound(example.name.clone()))?;

let prev = example_artifacts.insert(
example.name.clone(),
Expand Down
Loading