From 6833cc66d6f1ecb925a3c9825c531223e1b9f3f0 Mon Sep 17 00:00:00 2001 From: Garry Shutler Date: Mon, 8 Jul 2024 21:45:49 +0100 Subject: [PATCH] Correct error-raising logic (#266) --- lib/ews/types/calendar_folder.rb | 6 +++++- lib/ews/types/calendar_item.rb | 6 +++++- lib/ews/types/tasks_folder.rb | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/ews/types/calendar_folder.rb b/lib/ews/types/calendar_folder.rb index 0bf11ce1..a3b80e26 100644 --- a/lib/ews/types/calendar_folder.rb +++ b/lib/ews/types/calendar_folder.rb @@ -55,7 +55,11 @@ def create_item(attributes, to_ews_create_opts = {}) if rm && rm.success? CalendarItem.new ews, rm.items.first[:calendar_item][:elems].first else - raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" unless rm + if rm + raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" + else + raise EwsCreateItemError, "Could not create item in folder." + end end end diff --git a/lib/ews/types/calendar_item.rb b/lib/ews/types/calendar_item.rb index be81144a..5369441e 100644 --- a/lib/ews/types/calendar_item.rb +++ b/lib/ews/types/calendar_item.rb @@ -111,7 +111,11 @@ def update_item!(updates, options = {}) self.get_all_properties! self else - raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.message_text}" unless rm + if rm + raise EwsCreateItemError, "Could not update calendar item. #{rm.code}: #{rm.message_text}" + else + raise EwsCreateItemError, "Could not update calendar item." + end end end diff --git a/lib/ews/types/tasks_folder.rb b/lib/ews/types/tasks_folder.rb index 7228972b..ecbe1148 100644 --- a/lib/ews/types/tasks_folder.rb +++ b/lib/ews/types/tasks_folder.rb @@ -20,7 +20,11 @@ def create_item(attributes) if rm && rm.success? Task.new ews, rm.items.first[:task][:elems].first else - raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" unless rm + if rm + raise EwsCreateItemError, "Could not create item in folder. #{rm.code}: #{rm.message_text}" + else + raise EwsCreateItemError, "Could not create item in folder." + end end end end