From 2408349ec712aaba1ef72b9d79e9b76edfc70d03 Mon Sep 17 00:00:00 2001 From: daladim Date: Tue, 20 Apr 2021 00:00:18 +0200 Subject: [PATCH] More error checks --- examples/provider-sync.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/provider-sync.rs b/examples/provider-sync.rs index d3c9e6f..a026dd4 100644 --- a/examples/provider-sync.rs +++ b/examples/provider-sync.rs @@ -71,8 +71,12 @@ async fn add_items_and_sync_again( // Create a new calendar... let new_calendar_id: CalendarId = EXAMPLE_CREATED_CALENDAR_URL.parse().unwrap(); let new_calendar_name = "A brave new calendar".to_string(); - provider.local_mut().create_calendar(new_calendar_id.clone(), new_calendar_name.clone(), SupportedComponents::TODO) - .await.unwrap(); + if let Err(_err) = provider.local_mut() + .create_calendar(new_calendar_id.clone(), new_calendar_name.clone(), SupportedComponents::TODO) + .await { + println!("Unable to add calendar, maybe it exists already. We're not adding it after all."); + } + // ...and add a task in it let new_name = "This is a new task in a new calendar"; let new_task = Task::new(String::from(new_name), true, &new_calendar_id);