mirror of
https://github.com/googleworkspace/cli.git
synced 2026-09-14 16:47:13 +08:00
fix: replace unwrap() on required arguments in calendar helper
Replaced `.unwrap()` calls for `calendar`, `summary`, `start`, and `end` arguments with proper error handling using `.ok_or_else()`. This prevents potential panics if the `clap` configuration were to change and instead returns a structured `GwsError::Validation` error. Added a changeset file for `@googleworkspace/cli` as a patch-level update. Co-authored-by: jpoehnelt <3392975+jpoehnelt@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@googleworkspace/cli": patch
|
||||
---
|
||||
|
||||
Remove unwrap() on required arguments in the calendar helper to improve error handling and prevent potential panics.
|
||||
+12
-4
@@ -424,10 +424,18 @@ fn build_insert_request(
|
||||
matches: &ArgMatches,
|
||||
doc: &crate::discovery::RestDescription,
|
||||
) -> Result<(String, String, Vec<String>), GwsError> {
|
||||
let calendar_id = matches.get_one::<String>("calendar").unwrap();
|
||||
let summary = matches.get_one::<String>("summary").unwrap();
|
||||
let start = matches.get_one::<String>("start").unwrap();
|
||||
let end = matches.get_one::<String>("end").unwrap();
|
||||
let calendar_id = matches
|
||||
.get_one::<String>("calendar")
|
||||
.ok_or_else(|| GwsError::Validation("Missing required argument: calendar".to_string()))?;
|
||||
let summary = matches
|
||||
.get_one::<String>("summary")
|
||||
.ok_or_else(|| GwsError::Validation("Missing required argument: summary".to_string()))?;
|
||||
let start = matches
|
||||
.get_one::<String>("start")
|
||||
.ok_or_else(|| GwsError::Validation("Missing required argument: start".to_string()))?;
|
||||
let end = matches
|
||||
.get_one::<String>("end")
|
||||
.ok_or_else(|| GwsError::Validation("Missing required argument: end".to_string()))?;
|
||||
let location = matches.get_one::<String>("location");
|
||||
let description = matches.get_one::<String>("description");
|
||||
let attendees_vals = matches.get_many::<String>("attendee");
|
||||
|
||||
Reference in New Issue
Block a user