Skip to content

Commit 9b4d3b1

Browse files
committed
refactor: improve error handling and update deprecation warnings in ConnectHandler
1 parent 3238613 commit 9b4d3b1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

apps/gpclient/src/connect.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{borrow::Cow, cell::RefCell, fs, sync::Arc};
22

3-
use anyhow::bail;
3+
use anyhow::{Context, bail};
44
use clap::Args;
55
use common::constants::{GP_CLIENT_VERSION, GP_USER_AGENT};
66
use gpapi::{
@@ -211,11 +211,15 @@ impl<'a> ConnectHandler<'a> {
211211

212212
// Warn if deprecated options are used and will be removed in the future
213213
if self.args.csd_user.is_some() {
214-
warn!("The '--csd-user' option is deprecated and will be removed in future releases, please use the '--hip-user' option instead");
214+
warn!(
215+
"The '--csd-user' option is deprecated and will be removed in future releases, please use the '--hip-user' option instead"
216+
);
215217
}
216218

217219
if self.args.csd_wrapper.is_some() {
218-
warn!("The '--csd-wrapper' option is deprecated and will be removed in future releases, please use the '--hip' option instead");
220+
warn!(
221+
"The '--csd-wrapper' option is deprecated and will be removed in future releases, please use the '--hip' option instead"
222+
);
219223
}
220224

221225
self.latest_key_password.replace(self.args.key_password.clone());
@@ -516,7 +520,6 @@ impl<'a> ConnectHandler<'a> {
516520

517521
self.args.csd_user.clone()
518522
}
519-
520523
}
521524

522525
fn read_cookie_from_stdin() -> anyhow::Result<Credential> {
@@ -525,10 +528,7 @@ fn read_cookie_from_stdin() -> anyhow::Result<Credential> {
525528
let mut cookie = String::new();
526529
std::io::stdin().read_line(&mut cookie)?;
527530

528-
let Ok(auth_result) = serde_json::from_str::<SamlAuthResult>(cookie.trim_end()) else {
529-
bail!("Failed to parse auth data")
530-
};
531-
531+
let auth_result = serde_json::from_str::<SamlAuthResult>(cookie.trim_end()).context("Failed to parse auth data")?;
532532
Credential::try_from(auth_result)
533533
}
534534

0 commit comments

Comments
 (0)