Skip to content

Commit a1f3f14

Browse files
committed
Improve sign up error handling
1 parent 259461d commit a1f3f14

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/command/auth.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{rpc, settings, Result};
1+
use crate::{rpc, settings, verbosity, Result};
22
use clap::Args;
33
use serde_json::json;
44

@@ -9,11 +9,18 @@ pub struct SignUpArgs {
99
}
1010

1111
pub fn sign_up(args: &SignUpArgs) -> Result<()> {
12-
rpc::call(
12+
let add_user_response = rpc::call(
1313
"add_user",
1414
json!({"name": args.name, "password": args.password}),
15-
)?
16-
.print()?;
15+
)?;
16+
if add_user_response.error.is_some() {
17+
if verbosity() == 0 {
18+
eprintln!("Login failed, use verbose mode to see more details");
19+
} else {
20+
eprintln!("Login failed")
21+
}
22+
return Ok(());
23+
}
1724
let res = rpc::call(
1825
"create_api_key",
1926
json!({"username": args.name, "password": args.password, "label": "Created by btcmap-cli during signup"}),

0 commit comments

Comments
 (0)