Skip to content

Commit

Permalink
fix: print proper error when there are no profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed Feb 11, 2022
1 parent c32627e commit d9aad2c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/houston/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum HoustonProblem {
ProfileNotFound(String),

/// NoProfilesFound occurs when there are no profiles at all, often for new users
#[error("No configuration profiles found")]
#[error("No configuration profiles were found, and this command requires one.")]
NoConfigProfiles,

/// NoNonSensitiveConfigFound occurs when non-sensitive config can't be found for a profile.
Expand Down
8 changes: 4 additions & 4 deletions crates/houston/src/profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ impl Profile {
))
} else {
let profiles_base_dir = Profile::base_dir(config);
if let Ok(mut base_dir) = fs::read_dir(profiles_base_dir) {
if base_dir.next().is_none() {
return Err(HoustonProblem::NoConfigProfiles);
}
let mut base_dir_contents =
fs::read_dir(profiles_base_dir).map_err(|_| HoustonProblem::NoConfigProfiles)?;
if base_dir_contents.next().is_none() {
return Err(HoustonProblem::NoConfigProfiles);
}
Err(HoustonProblem::ProfileNotFound(profile_name.to_string()))
}
Expand Down
2 changes: 1 addition & 1 deletion src/error/metadata/codes/E020.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This error occurs when trying to run a command that needs to use a configuration

This is likely because you haven't set up a configuration profile yet or your `APOLLO_KEY` has been removed.

Run `apollo config auth` to set up a new configuration profile or check out Rover's [configuration docs](https://go.apollo.dev/r/configuring) for more on how to set up and use Rover.
Run `rover config auth` to set up a new configuration profile or check out Rover's [configuration docs](https://go.apollo.dev/r/configuring) for more on how to set up and use Rover.
4 changes: 2 additions & 2 deletions src/error/metadata/suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ impl Display for Suggestion {
"When trying to compose with a local .graphql file, make sure you supply a `routing_url` in your config YAML.".to_string()
}
Suggestion::NewUserNoProfiles => {
format!("It looks like you may be new here (we couldn't find any existing config profiles). To authenticate with Apollo Studio, run {}",
Yellow.normal().paint("`rover config auth`")
format!("It looks like you may be new here. Welcome! To authenticate with Apollo Studio, run {}, or set {} to a valid Apollo Studio API key.",
Yellow.normal().paint("`rover config auth`"), Cyan.normal().paint(format!("`${}`", RoverEnvKey::Key))
)
}
Suggestion::Adhoc(msg) => msg.to_string(),
Expand Down
4 changes: 2 additions & 2 deletions src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub(crate) use metadata::Metadata;
pub type Result<T> = std::result::Result<T, RoverError>;

use ansi_term::Colour::Red;
use calm_io::{stderrln, stdoutln};
use calm_io::{stderr, stdoutln};
use rover_client::RoverClientError;
use serde::ser::SerializeStruct;
use serde::{Serialize, Serializer};
Expand Down Expand Up @@ -106,7 +106,7 @@ impl RoverError {
stdoutln!("{}", check_response.get_table())?;
}

stderrln!("{}", self)?;
stderr!("{}", self)?;
Ok(())
}

Expand Down

0 comments on commit d9aad2c

Please sign in to comment.