这是indexloc提供的服务,不要输入任何密码
Skip to content

chore: use proper grammar in error messages #9685

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
merged 11 commits into from
Jan 18, 2025
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
4 changes: 2 additions & 2 deletions crates/turborepo-analytics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ static REQUEST_TIMEOUT: Duration = Duration::from_secs(10);

#[derive(Debug, Error)]
pub enum Error {
#[error("Failed to send analytics event")]
#[error("Failed to send analytics event.")]
SendError(#[from] mpsc::error::SendError<AnalyticsEvent>),
#[error("Failed to record analytics")]
#[error("Failed to record analytics.")]
Join(#[from] JoinError),
}

Expand Down
6 changes: 3 additions & 3 deletions crates/turborepo-api-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ pub enum Error {
ReadError(#[from] std::io::Error),
#[error("Error making HTTP request: {0}")]
ReqwestError(#[from] reqwest::Error),
#[error("skipping HTTP Request, too many failures have occurred.\nLast error: {0}")]
#[error("Skipping HTTP Request. Too many failures have occurred.\nLast error: {0}")]
TooManyFailures(#[from] Box<reqwest::Error>),
#[error("Unable to set up TLS.")]
TlsError(#[source] reqwest::Error),
#[error("Error parsing header: {0}")]
InvalidHeader(#[from] ToStrError),
#[error("Error parsing '{url}' as URL: {err}")]
InvalidUrl { url: String, err: url::ParseError },
#[error("unknown caching status: {0}")]
#[error("Unknown caching status: {0}")]
UnknownCachingStatus(String, #[backtrace] Backtrace),
#[error("unknown status {code}: {message}")]
#[error("Unknown status {code}: {message}")]
UnknownStatus {
code: String,
message: String,
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-api-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ mod test {
.unwrap(),
);
let err = APIClient::handle_403(response).await;
assert_snapshot!(err.to_string(), @"unknown status forbidden: Not authorized");
assert_snapshot!(err.to_string(), @"Unknown status forbidden: Not authorized");
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-auth/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum Error {
APIError(#[from] turborepo_api_client::Error),

#[error(
"loginUrl is configured to \"{value}\", but cannot be a base URL. This happens in \
"`loginUrl` is configured to \"{value}\", but cannot be a base URL. This happens in \
situations like using a `data:` URL."
)]
LoginUrlCannotBeABase { value: String },
Expand Down
12 changes: 7 additions & 5 deletions crates/turborepo-cache/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,41 @@ use crate::{CacheActions, CacheConfig};

#[derive(Debug, Error, Diagnostic, PartialEq)]
pub enum Error {
#[error("keys cannot be duplicated, found `{key}` multiple times")]
#[error("Keys cannot be duplicated. Found `{key}` multiple times.")]
DuplicateKeys {
#[source_code]
text: String,
key: &'static str,
#[label]
span: Option<SourceSpan>,
},
#[error("actions cannot be duplicated, found `{action}` multiple times")]
#[error("Actions cannot be duplicated. Found `{action}` multiple times.")]
DuplicateActions {
#[source_code]
text: String,
action: &'static str,
#[label]
span: Option<SourceSpan>,
},
#[error("invalid cache type and action pair, found `{pair}`, expected colon separated pair")]
#[error(
"Invalid cache type and action pair. Found `{pair}`, but expected colon separated pair."
)]
InvalidCacheTypeAndAction {
#[source_code]
text: String,
pair: String,
#[label]
span: Option<SourceSpan>,
},
#[error("invalid cache action `{c}`")]
#[error("Invalid cache action: `{c}`")]
InvalidCacheAction {
#[source_code]
text: String,
c: char,
#[label]
span: Option<SourceSpan>,
},
#[error("invalid cache type `{s}`, expected `local` or `remote`")]
#[error("Invalid cache type `{s}`. Expected `local` or `remote`")]
InvalidCacheType {
#[source_code]
text: String,
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-cache/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ mod test {
backtrace: Backtrace::capture(),
},
);
assert_snapshot!(err.to_string(), @"failed to contact remote cache: unknown status unknown: Special message");
assert_snapshot!(err.to_string(), @"failed to contact remote cache: Unknown status unknown: Special message");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-dirs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ pub fn vercel_config_dir() -> Result<Option<AbsoluteSystemPathBuf>, PathError> {

#[derive(Debug, Error)]
pub enum Error {
#[error("config directory not found")]
#[error("Config directory not found.")]
ConfigDirNotFound,
}
8 changes: 4 additions & 4 deletions crates/turborepo-filewatch/src/globwatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ impl GlobSet {
pub enum Error {
#[error(transparent)]
CookieError(#[from] CookieError),
#[error("failed to send query to globwatcher: {0}")]
#[error("Failed to send query to glob watcher: {0}")]
SendError(#[from] mpsc::error::SendError<CookiedRequest<Query>>),
#[error("globwatcher has closed")]
#[error("Glob watcher has closed.")]
Closed,
#[error("globwatcher request timed out")]
#[error("Glob watcher request timed out.")]
Timeout(#[from] tokio::time::error::Elapsed),
#[error("glob watching is unavailable")]
#[error("Glob watching is unavailable.")]
Unavailable,
}

Expand Down
8 changes: 4 additions & 4 deletions crates/turborepo-filewatch/src/hash_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ impl HashSpec {

#[derive(Error, Debug)]
pub enum Error {
#[error("package hashing encountered an error: {0}")]
#[error("Package hashing encountered an error: {0}")]
HashingError(String),
#[error("file hashing is not available: {0}")]
#[error("File hashing is not available: {0}")]
Unavailable(String),
#[error("package not found: {} {:?}", .0.package_path, .0.inputs)]
#[error("Package not found: {} {:?}", .0.package_path, .0.inputs)]
UnknownPackage(HashSpec),
#[error("unsupported: glob traverses out of the package")]
#[error("Unsupported: glob traverses out of the package")]
UnsupportedGlob,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum Error {
Path(#[from] turbopath::PathError),
#[error(transparent)]
Io(#[from] io::Error),
#[error("error walking directory during recursive copy: {0}")]
#[error("Error walking directory during recursive copy: {0}")]
Walk(#[from] ignore::Error),
}

Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-graph-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
#[error("cyclic dependency detected:\n{0}")]
#[error("Cyclic dependency detected:\n{0}")]
CyclicDependencies(String),
#[error("{0} depends on itself")]
SelfDependency(String),
Expand Down Expand Up @@ -103,7 +103,7 @@ mod test {
assert!(result.is_err());
let err = result.unwrap_err();
assert_snapshot!(err.to_string(), @r###"
cyclic dependency detected:
Cyclic dependency detected:
d, c, b, a
"###);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/cli/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{

#[derive(Debug, Error, Diagnostic)]
pub enum Error {
#[error("No command specified")]
#[error("No command specified.")]
NoCommand(#[backtrace] backtrace::Backtrace),
#[error("{0}")]
Bin(#[from] bin::Error, #[backtrace] backtrace::Backtrace),
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/commands/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
#[error("could not get path to turbo binary: {0}")]
#[error("Could not get path to `turbo` binary: {0}")]
NoCurrentExe(#[from] io::Error),
}

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/commands/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{DaemonConnector, DaemonConnectorError};

#[derive(Debug, Error)]
pub enum Error {
#[error("could not get path to turbo binary: {0}")]
#[error("Could not get path to `turbo` binary: {0}")]
NoCurrentExe(#[from] io::Error),
}

Expand Down
22 changes: 11 additions & 11 deletions crates/turborepo-lib/src/commands/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,35 @@ pub enum Error {
UsageLimit,
#[error("spending paused")]
SpendingPaused,
#[error("could not find home directory.")]
#[error("Could not find home directory.")]
HomeDirectoryNotFound,
#[error("User not found. Please login to Turborepo first by running {command}.")]
TokenNotFound { command: StyledObject<&'static str> },
// User decided to not link the remote cache
#[error("link cancelled")]
#[error("Link cancelled.")]
NotLinking,
#[error("canceled")]
#[error("Canceled.")]
UserCanceled(#[source] dialoguer::Error),
#[error("could not get user information {0}")]
#[error("Could not get user information: {0}")]
UserNotFound(#[source] turborepo_api_client::Error),
// We failed to fetch the team for whatever reason
#[error("could not get information for team {1}")]
#[error("Could not get information for team: {1}")]
TeamRequest(#[source] turborepo_api_client::Error, String),
// We fetched the team, but it doesn't exist.
#[error("could not find team {0}")]
#[error("Could not find team: {0}")]
TeamNotFound(String),
#[error("could not get teams information")]
#[error("Could not get teams information.")]
TeamsRequest(#[source] turborepo_api_client::Error),
#[error("could not get spaces information")]
#[error("Could not get spaces information.")]
SpacesRequest(#[source] turborepo_api_client::Error),
#[error("could not get caching status")]
#[error("Could not get caching status.")]
CachingStatusNotFound(#[source] turborepo_api_client::Error),
#[error("Failed to open browser. Please visit {0} to enable Remote Caching")]
OpenBrowser(String, #[source] io::Error),
#[error("please re-run `link` after enabling caching")]
#[error("Please re-run `link` after enabling caching.")]
EnableCaching,
#[error(
"Could not persist selected space ({space_id}) to `experimentalSpaces.id` in turbo.json"
"Could not persist selected space ({space_id}) to `experimentalSpaces.id` in turbo.json."
)]
WriteToTurboJson {
space_id: String,
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/commands/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{

#[derive(Debug, Error, Diagnostic)]
pub enum Error {
#[error("package `{package}` not found")]
#[error("Package `{package}` not found.")]
PackageNotFound { package: String },
}

Expand Down
16 changes: 8 additions & 8 deletions crates/turborepo-lib/src/commands/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ pub const DEFAULT_OUTPUT_DIR: &str = "out";

#[derive(Debug, thiserror::Error, Diagnostic)]
pub enum Error {
#[error("io error while pruning: {0}")]
#[error("I/O error while pruning: {0}")]
Io(#[from] std::io::Error),
#[error("File system error while pruning. The error from the operating system is: {0}")]
Fs(#[from] turborepo_fs::Error),
#[error("json error while pruning: {0}")]
#[error("JSON error while pruning: {0}")]
Json(#[from] serde_json::Error),
#[error("path error while pruning: {0}")]
#[error("Path error while pruning: {0}")]
Path(#[from] turbopath::PathError),
#[error(transparent)]
#[diagnostic(transparent)]
Expand All @@ -39,15 +39,15 @@ pub enum Error {
PackageGraph(#[from] package_graph::Error),
#[error(transparent)]
Lockfile(#[from] turborepo_lockfiles::Error),
#[error("turbo doesn't support workspaces at file system root")]
#[error("`turbo` does not support workspaces at file system root.")]
WorkspaceAtFilesystemRoot,
#[error("at least one target must be specified")]
#[error("At least one target must be specified.")]
NoWorkspaceSpecified,
#[error("invalid scope: package with name {0} in package.json not found")]
#[error("Invalid scope. Package with name {0} in `package.json` not found.")]
MissingWorkspace(PackageName),
#[error("Cannot prune without parsed lockfile")]
#[error("Cannot prune without parsed lockfile.")]
MissingLockfile,
#[error("Prune is not supported for Bun")]
#[error("`prune` is not supported for Bun.")]
BunUnsupported,
#[error("Unable to read config: {0}")]
Config(#[from] crate::config::Error),
Expand Down
Loading
Loading