summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Geier <geier@lostpackets.de>2023-05-24 11:59:44 +0200
committerGitHub <noreply@github.com>2023-05-24 11:59:44 +0200
commite888014e0b2bfb2e6d22d1857d8b24a7823fa2fa (patch)
treebc74c6644c82a3213d0df56455b5dea3d60140d8
parentd7d33bb4472a8aa6001df1bf8aef23719063004a (diff)
parent3252819ee8294df662054a3bbb8b33f2c1a1af19 (diff)
Merge pull request #1256 from pimutils/feature/more_warning
more warnings on failing to import events
-rw-r--r--khal/icalendar.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/khal/icalendar.py b/khal/icalendar.py
index b9d6334a..29fa60cb 100644
--- a/khal/icalendar.py
+++ b/khal/icalendar.py
@@ -72,8 +72,19 @@ def split_ics(ics: str, random_uid: bool=False, default_timezone=None):
events_grouped[item['UID']].append(item)
else:
continue
- return [ics_from_list(events, tzs, random_uid, default_timezone) for uid, events in
- sorted(events_grouped.items())]
+ out = []
+ saved_exception = None
+ for uid, events in sorted(events_grouped.items()):
+ try:
+ ics = ics_from_list(events, tzs, random_uid, default_timezone)
+ except Exception as exception:
+ logger.warn(f'Error when trying to import the event {uid}')
+ saved_exception = exception
+ else:
+ out.append(ics)
+ if saved_exception:
+ raise saved_exception
+ return out
def new_vevent(locale,
@@ -418,6 +429,9 @@ def sanitize_timerange(dtstart, dtend, duration=None):
"Assuming it's the same timezone as the end time"
)
dtstart = dtend.tzinfo.localize(dtstart)
+ if dtend is not None and type(dtstart) != type(dtend):
+ raise ValueError(
+ 'The event\'s end time (DTEND) and start time (DTSTART) are not of the same type.')
if dtend is None and duration is None:
if isinstance(dtstart, dt.datetime):