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

CLI: print error source #740

Merged
merged 1 commit into from
Jul 16, 2024
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
21 changes: 21 additions & 0 deletions cli/src/cmd_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,27 @@ impl CmdAuthStatus {

#[cfg(test)]
mod tests {
#[test]
fn test_cmd_auth_login() {
use assert_cmd::Command;
use predicates::str;

let bad_url = "sys.oxide.invalid";

// Validate connection error details are printed
Command::cargo_bin("oxide")
.unwrap()
.arg("auth")
.arg("login")
.arg("--host")
.arg(bad_url)
.assert()
.failure()
.stderr(str::starts_with(format!(
"Request failed: error sending request for url (https://{bad_url}/device/auth):"
)));
}

#[test]
fn test_parse_host() {
use super::parse_host;
Expand Down
3 changes: 2 additions & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ async fn main() {
.await
.unwrap();
if let Err(e) = result {
eprintln!("{e}");
let src = e.source().map(|s| format!(": {s}")).unwrap_or_default();
eprintln!("{e}{src}");
std::process::exit(1)
}
}
Expand Down
Loading