Skip to content

Commit 1c774c4

Browse files
feat(login): Improve error output for login errors (#2581)
If there is an underlying cause to the error, this is now included in the error output. This change also corrects the output, removing the "Invalid token" from the error message, as not all errors will be caused by invalid tokens. May assist in debugging #2577.
1 parent 572d447 commit 1c774c4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/commands/login.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::env;
22

3-
use anyhow::{bail, Result};
3+
use anyhow::Result;
44
use clap::{Arg, ArgAction, ArgMatches, Command};
55
use url::Url;
66

@@ -88,11 +88,13 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
8888
break;
8989
}
9090
Err(err) => {
91-
let msg = format!("Invalid token: {err}");
91+
// Convert to anyhow error to take advantage of anyhow's Debug impl
92+
let err = anyhow::anyhow!(err);
93+
9294
if has_predefined_token {
93-
bail!(msg);
95+
return Err(err);
9496
} else {
95-
println!("{msg}");
97+
println!("Error: {err:?}");
9698
}
9799
}
98100
}

0 commit comments

Comments
 (0)